Sergej Chodarev
Sergej Chodarev
java.lang.reflect.Proxy
ClassLoader
InvocationHandler
Object proxy = Proxy.newProxyInstance(
SomeInterface.class.getClassLoader(),
new Class[]{ SomeInterface.class },
invocationHandler);
InvocationHandler
Object
:
hashCode()
, equals()
, toString()
Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
Class cls = Class.forName(name);
ClassLoader loader = this.getClass().getClassLoader();
Class cls = Class.forName(name, true, loader);
Class cls = loader.loadClass(name);
this.getClass().getClassLoader();
ClassLoader.getSystemClassLoader();
Thread.currentThread().getContextClassLoader();
new URLClassLoader(urls);
Class<?> Class.forName(String className)
ClassName.class
?
String dbClassName = props.getProperty("dbClass", "sk.tuke.StubDB");
Class dbClass = Class.forName(dbClassName);
customerDB = (CustomerDatabase) dbClass.newInstance();
int x = 5;
int y = 10;
int z = x + y * 7;
0: iconst_5
1: istore_1
2: bipush 10
4: istore_2
5: iload_1
6: iload_2
7: bipush 7
9: imul
10: iadd
11: istore_3
java -javaagent:agent.jar -jar app.jar
https://git.kpi.fei.tuke.sk/meta/examples/reflection-performance