My thoughts as an enterprise Java developer.

Thursday, August 18, 2005

IncompatibleClassChangeError

I just delivered a patch to SQA and got a IncompatibleClassChangeError. The javadoc description doesn't help much.

Thrown when an incompatible class change has occurred to some class definition. The definition of some class, on which the currently executing method depends, has since changed.


I looked at the line of code that had the error and went on a hunch. In my case a class used a variable in a super-class and I had changed that variable from static to instance. Therefore the class file in the patch was trying to access it as an instance variable but the old super-class still had it as a static variable. I changed the patch class to not use that variable and sent it back to SQA. Hopefully that fixes it.

Friday, August 12, 2005

Finding the file for a class

From http://java.sys-con.com/read/117751_2.htm

Classpath Problems
Another class of problems are classpath issues. There are times when you are not sure if there is another version of a class in the classpath that is getting picked up before yours, usually a result of a bad environment setup. To eliminate this possibility, a simple check is to add a print statement to see if your new code gets picked up. If it isn't getting picked up, you need to locate the other class that is getting picked up. One neat API in Java that allows you to locate where a class is being picked up is:

Class.getProtectionDomain().getCodeSource().getLocation()

In most cases, depending on the class loader being used, you'll get the location of the class that is being executed and you can correct your environment setup.