在静态方法中(用@CallerSensitive注释)我尝试获取调用类的名称:@CallerSensitivepublicstaticvoidsomeMethod(){Stringname=sun.reflect.Reflection.getCallerClass().getName();...}我得到错误:java.lang.InternalError:CallerSensitiveannotationexpectedatframe1这里有什么问题吗?引用资料http://www.infoq.com/news/2013/07/Oracle-Removes-getCallerClass
@CallerSensitive注解上述方法的含义是什么?例如,注解存在于Class的getClassLoader方法中@CallerSensitivepublicClassLoadergetClassLoader(){//} 最佳答案 根据我在评论中链接的JEP(也是here),Acaller-sensitivemethodvariesitsbehavioraccordingtotheclassofitsimmediatecaller.Itdiscoversitscaller’sclassbyinvokingthesun.refl
@CallerSensitive注解上述方法的含义是什么?例如,注解存在于Class的getClassLoader方法中@CallerSensitivepublicClassLoadergetClassLoader(){//} 最佳答案 根据我在评论中链接的JEP(也是here),Acaller-sensitivemethodvariesitsbehavioraccordingtotheclassofitsimmediatecaller.Itdiscoversitscaller’sclassbyinvokingthesun.refl