今天莫名其妙的遇到了这个错误,原因是我把jar包放在了不同的位置,导致了修饰符范围发生改变,然后就访问不到原有的方法和属性了。
api中原文是这样的
Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.
Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.
意思就说的是程序试图访问或修改一个属性或调用一个方法,这个属性或方法,你没有权限访问。一般的,这个会引起编译器异常。这个错误如果发生在运行时,就说明一个类发生了不兼容的改变。
本来我的jar包是放在和class一个包内的,我访问的是默认权限修饰符的属性,然后我把jar包放到了包外,此时再运行原程序,就会发生这个错误。