什么原因导致java.lang.IncompatibleClassChangeError? [英] What causes java.lang.IncompatibleClassChangeError?

查看:1883
本文介绍了什么原因导致java.lang.IncompatibleClassChangeError?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打包一个Java库作为JAR,当我尝试从它调用方法时,它抛出许多 java.lang.IncompatibleClassChangeError s。这些错误似乎随机出现。

解决方案

这意味着你对库进行了一些不兼容的二进制修改而不重新编译客户端代码。 Java语言规范§13详细说明了所有这些更改,最显着的是,将非私有字段/方法更改为 static ,反之亦然。 p>

根据新库重新编译客户端代码,你应该很好。



更新:如果发布一个公共库,你应该尽量避免做不兼容的二进制更改,以保留所谓的二进制向下兼容性。更新依赖项jar单独理想地不应该打破应用程序或构建。


I'm packaging a Java library as a JAR, and it's throwing many java.lang.IncompatibleClassChangeErrors when I try to invoke methods from it. These errors seem to appear at random. What kinds of problems could be causing this error?

解决方案

This means that you have made some incompatible binary changes to the library without recompiling the client code. Java Language Specification §13 details all such changes, most prominently, changing non-static non-private fields/methods to be static or vice versa.

Recompile the client code against the new library, and you should be good to go.

UPDATE: If you publish a public library, you should avoid making incompatible binary changes as much as possible to preserve what's known as "binary backward compatibility". Updating dependency jars alone ideally shouldn't break the application or the build.

这篇关于什么原因导致java.lang.IncompatibleClassChangeError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆