Thursday, October 25, 2007

LinkageError and some Class Loading issues

Consider the code:
setAbc(Abc obj){ = obj; //Abc abc;
Do we need the Class Abc in classpath while invoking this method? Not really! However when you invoke this method second time with an Object with a different ClassLoader (than the ClassLoader of the Object in the first invocation) you will get the following error:
LinkageError: loader constraints violated when linking Abc class
See the attached code for demonstration.

No comments: