被代理類爲何要依託一個接口才能生存代理類?
-
什麼時候會生成反編譯結果?
-
如何查看反編譯後結果?
System.getProperties().put("jdk.proxy.ProxyGenerator.saveGeneratedFiles", "true");
如何查看 Proxy 模式的 $ProxyX.class文件
System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", true);//這個不對
- 註解的本質是什麼?
@Target(value = {ElementType.FIELD, ElementType.METHOD})
@Retention(value = RetentionPolicy.RUNTIME)
public @interface Hello {
String value();
}
public class Test {
@Hello("hi")
public static void main(String[] args) throws Exception {
System.getProperties().put("jdk.proxy.ProxyGenerator.saveGeneratedFiles", "true");
//System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
Class<Test> cls = Test.class;
Method method = cls.getMethod("main", String[].class);
Hello hello = method.getAnnotation(Hello.class);
}
}