Sometimes you need to implement code with reflection. Direct use of tools, Joor
On the code:
PackageCom.ming.joor;Import Staticorg.joor.reflect.*; Public classTest {PrivateString name= "AA"; Public Static voidMain (string[] args) {on (NewTest ()). Call ("AA");//calling methods directlyString Name=on (NewTest ()). Get ("name");//Calling Properties directlySystem.out.println (name); On (NewA ()). As (Stringproxy.class). AA (1);//use the object first, then go to the interface, and finally invoke the implementation of the method//basically enough. } Public voidAA () {System.out.println ("DDDDDDD"); } } Interfacestringproxy {String substring (intbeginindex); voidAainta); } classAImplementsstringproxy{@Override PublicString substring (intbeginindex) { return NULL; } @Override Public voidAainta) {System.out.println ("A" +a); } }
Joor Source Address: Https://github.com/jOOQ/jOOR
Things that are useful should be used directly.
Java Joor implements reflection simple invocation