为什么要让一个方法在java中易失性?
为什么一种方法会变得不稳定?使方法易失性如何改变方法的行为?
编辑:我对类对象返回的方法对象(Java Reflection)做了一个toString()。返回字符串具有针对方法名称的可变修饰符以及公共可见性和 void 返回类型。研究仅产生有关属性挥发性的信息。这就是我问这个问题的原因。
方法声明为:
public volatile org.osmdroid.api.IGeoPoint org.osmdroid.views.MapView.getMapCenter()
反射方法的代码:
public static class Test {
public static void showMethods(Object target) {
Class<?> clazz = target.getClass();
for (Method method : clazz.getMethods()) {
if (method!=null) {
System.out.println(method.toString());
}
}
}
}
方法调用:
Test.showMethods(mapView);