Reputation: 179
In Oracle's Java - Essential Classes Trail I found the following statement:
Error Class
When a dynamic linking failure or other hard failure in the Java virtual machine occurs, the virtual machine throws an Error. [...]
What exactly is meant by dynamic linking failure in the context of Java and the JVM? Is this related to issues the classloader might encounter at runtime?
Upvotes: 2
Views: 1892
Reputation: 5948
In Java you can load Class object dynamically and the logic that verifies if that Class and its instances are compatible with currently loaded classes is called a dynamic linkage.
Here are examples when you can get linkage failures in form of java.lang.LinkageError:
1) You have class and interface. You later modify that interface method signatures and start VM with that new interface. Now if you go and dynamically try to load your class you will get linkage failure since the class is compiled with old version of interface method signatures and wont be able to work with new interface method signature.
2) You load same class from class loader CL1 and CL2. You then create object o1 from that class loaded by CL1 and use that object in the code that is is loaded by CL2.
Upvotes: 2