For some reason our java library that we package as a jar is throwing all of these java.lang.IncompatibleClassChangeError
when we try to invoke methods from it. It seems to be seemingly random. What would cause this error?
views:
3681answers:
2
+8
A:
This means that you have made some incompatible binary changes to the library without recompiling the client code. Java Language Specification S13 details all of such changes, most prominantly, changing non-static
non-private fields/methods as static
or visa-versa.
Recompile the client code against the new library, and you should be good to go.
UPDATE: If you publishing a public library, you avoid making incompatible binary changes as much as possible, and preserving what's known as "binary backward compatibility". Updating dependency jars alone ideally shouldn't break the application or the build.
notnoop
2009-12-30 14:31:12
For some reason the developers here are having a problem where recompiling the client code doesn't fix the issue exactly. For some reason if they edit the file where it occurs and recompile the error no longer occurs there, but more will randomly pop-up elsewhere in the project, where the library is referenced. I am curious what could possibly be casuing this.
Zombies
2009-12-30 15:42:36
Is there any dynamically generated code?
Kristopher Ives
2009-12-30 15:50:51
Have you tried to do a clean build (delete all the `*.class` files) and recompiling? Editing files have similar effect.
notnoop
2009-12-30 15:52:52
No dynamically generated code.... unless you would consider a JSP to be such. We did try deleting the class files and this didn't seem to help. The wierd thing is that it just doesn't seem to happen for me but it happens for other developer.
Zombies
2009-12-30 16:54:43
Can you ensure that when you do a clean build you are compiling against the same jars you run with?
notnoop
2009-12-30 19:18:42
A:
Thanks. This really helped me. I and the team was struggling over this since last couple of days. We didnt knew the root cause.
Thanks again.
Utkarsh Shah
2010-04-06 14:40:10