1.Class.forName("") 将class文件加载至java虚拟机
多次调用,若果jvm已加载,则会直接返回内存中的,不会重复加载。内存中只会存在一个。
2.接口和实现类的注解类型即使相同,也是不同的注解对象即动态修改接口中的注解值,并不会影响实现类的注解值
3.getMethod与getDeclareMethod获取的方法即使相同,但实际指向的方法对象是不同的。方法对象持有相同类型但不是同一引用的注解
3.动态代理method是通过getMethod形式获取的。
注解:
@Target({ElementType.METHOD,ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Foo {
String value();
}
public interface Parent {
@Foo ("fff")
void hello(String dd);
}
public class Bar implements Parent{
@Override
@Foo("fdfd")
public void hello(String hell){
System.out.println("----------"+hell);
}
}
public class Main {
//动态修改注解
public void changezhujie(Class myclass) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodExceptio