Thursday, October 25, 2007

LinkageError and some Class Loading issues

Consider the code:
setAbc(Abc obj){
this.abc = 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.
http://rejeev.googlepages.com/source_code_LinkageError.zip

No comments: