What causes “java.lang.IncompatibleClassChangeError: vtable stub”?

心已入冬 提交于 2019-12-03 15:19:19

ABI breakage in the JVM byte-code world. Look up the Javadoc: “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.”

Culprits to look for would be changes to static final literal values because these get copied around in the byte code as “optimization”. EDIT: This can be as simple as the result of a library upgrade, the only fix I know of is a clean rebuild.

Looks like you have changed the class definition ( ie adding an extra attribute or something more weird ) and when running your previously used objects become incompatible.

Perhaps you're storing object instances somewhere ( a db the filesystem ) and then those old objects definition are unmarshalled, the error occurs.

It happened to me in the past.

For instance:

class Employee implements Serialiable {
   String name;
   String lastName;
   String address;
   ... etc 
}

The application works for a couple of weeks and some objects are stored in the filesystem in its serialized version.

Later due an application change we have to add the address as an object:

class Employee implements Serializable {
   String name;
   String lastName;
   Address address;
 }

Then the previously stored objects are reconstituted and an attempt is made to make them fit in this new description, that error may raise ( in my case it was much more complex than this ) but it may help you to look in that direction.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!