Reputation: 9454
I have the following situation:
2 Eclipse projects in the same workspace, Apa and Bepa (pseudonyms for the sake of brevity).
Project Apa references (includes) project Bepa.
I have a class X in Bepa, with public method b(). Invoking X.b() directly works fine in project Bepa.
However, creating a reference to an instance of X in Apa, and then invoking b() on this reference, results in this:
Exception in thread "main" java.lang.IllegalAccessError: tried to access method java_cup.runtime.Symbol.<init>(II)V from class de.uni_freiburg.informatik.ultimate.smtinterpol.util.MySymbolFactory$LineColumnSymbol
at de.uni_freiburg.informatik.ultimate.smtinterpol.util.MySymbolFactory$LineColumnSymbol.<init>(MySymbolFactory.java:31)
at de.uni_freiburg.informatik.ultimate.smtinterpol.util.MySymbolFactory.startSymbol(MySymbolFactory.java:95)
at java_cup.runtime.LRParser.parse(LRParser.java:393)
at de.uni_freiburg.informatik.ultimate.smtinterpol.smtlib2.ParseEnvironment.parseStream(ParseEnvironment.java:152)
at de.uni_freiburg.informatik.ultimate.smtinterpol.smtlib2.ParseEnvironment.parseScript(ParseEnvironment.java:118)
at de.uni_freiburg.informatik.ultimate.smtinterpol.smtlib2.SMTLIB2Parser.run(SMTLIB2Parser.java:47)
at de.uni_freiburg.informatik.ultimate.smtinterpol.Main.main(Main.java:121)
at de.uka.ilkd.key.keynterpol.KeYnterpolInterface.main(KeYnterpolInterface.java:36)
From what I understand, the culprit is a third-party jar referenced by B. However, I cannot for the life of me figure out why I can only use it from within Bepa, and not Apa. Any help would be greatly appreciated.
Upvotes: 0
Views: 808
Reputation: 64959
IllegalAccessError is a subclass of IncompatibleClassChangeError. If an IncompatibleClassChangeError is thrown while your code is executing, this typically indicates that the your code isn't running with the same classes it was compiled against.
In your case, the method that is causing the IllegalAccessError to be thrown is a constructor of the java_cup.runtime.Symbol
class that has default visibility:
Symbol(int sym_num, int state)
{
sym = sym_num;
parse_state = state;
}
The code that calls this constructor is in a different package and so should not be able to call this constructor directly. Normally an error such as this is caught by the compiler, as attempting to access a package-private member from another package should cause a compiler error. In your case however, you don't appear to have any such compiler error.
If you are running your code with the same classpath that you're compiling it with, then I can only guess that the java_cup.*
classes appear more than once on the classpath, with different visibilities for the constructor above. The compiler must have found one copy of the Symbol
class with this constructor being public and the JVM must have found a copy that had this constructor package-private.
Upvotes: 2