Search and execute method by name from instance with processing (java)

I'll leave it because it's interesting

test.pde


import java.lang.reflect.*;
void setup(){
  Test test=new Test();
}

class Test{
  Test(){
    try{
      this.getClass().getMethod("test").invoke(this);
    }catch(NoSuchMethodException | e){
      println(e);
    }catch(IllegalAccessException e){
      println(e);
    }catch(InvocationTargetException e){
      println(e);
    }
  }
  void test(){
    println("test");
  }
}

Similarly in java

Recommended Posts

Search and execute method by name from instance with processing (java)
Using Java with AWS Lambda-Implementation Tips-Get Instance Name from Reagion and Instance ID
Execute Java code from cpp with cocos2dx
Method name of static factory method learned from Java 8
Call a method with a Kotlin callback block from Java
Search by POST request with Azure Search + Java Apache HttpClient
Find the address class and address type from the IP address with Java
[Kotlin] Get Java Constructor / Method from KFunction and call it
[Rails] Search from multiple columns + conditions with Gem and ransack
Java, instance starting from beginner
[Java] Timer processing implementation method
Java methods and method overloads
Execute non-Java instructions from Java
Solving with Ruby, Perl and Java AtCoder ABC 136 D Breadth-first search
[Java] Introductory structure Class definition Relationship between class and instance Method definition format
Memorandum No.2 "Making a search history with ArrayList and HashSet" [Java]
Read barometric pressure and temperature with Java from Raspberry Pi 3 & BMP180
Difference between instance method and class method
Use java with MSYS and Cygwin
Distributed tracing with OpenCensus and Java
Install Java and Tomcat with Ansible
Code Java from Emacs with Eclim
[Java] Loop processing and multiplication table
Screen transition by Post method [Java]
Run node.js from android java (processing)
Use JDBC with Java and Scala.
[Java beginner] == operator and equals method
Processing speed with and without static
Java pass by value and pass by reference
Execute packaged Java code with commands
Output PDF and TIFF with Java 8
Work with Google Sheets from Java
Server processing with Java (Introduction part.1)
[Java] Processing time measurement method memo
Encrypt with Java and decrypt with C #
[Java] Exception types and basic processing
Web application structure by Java and processing flow in the presentation layer
[Ruby / Refactoring] From Ruby iterative processing like Java and C language to Ruby-like iterative processing
[Java] Get Json from URL and handle it with standard API (javax.script)
Activity transition with JAVA class refactoring and instance experimented on Android side