开发者

NoSuchFieldError but the field is there

开发者 https://www.devze.com 2023-02-23 12:05 出处:网络
I just upgraded a library, and another one started throwing NoSuchFieldError. It would be fine, if the field was removed. But it stays. It\'s just deprecated.

I just upgraded a library, and another one started throwing NoSuchFieldError. It would be fine, if the field was removed. But it stays. It's just deprecated.

Hibernate.TIMESTAMP.nullSafeGet(null, null); // << works

new PersistentDateTime().nullSafeGet(null, null); // << throws NoSuchFieldError

where the the nullSafeGet method has:

Hibernate.TIMESTAMP.nullSafeGet(resultSet, string); 

(of course, the field that is not found is TIMESTAMP)

the correct version of the library is on the classpath (otherewise my manual test would not have worked as well开发者_如何学Go)

Why is that happening?

Update: I made a new class, overriding the old one, and defining the same method, with the exactly same code, and it works now. Any idea what's supposed to be happening in the bytecode?


Joshua Bloch explained this in his short presentation - static final fields are copied into the client library, so it should be recompiled when a constant changes.


The only thing I can think of is that PersistentDateTime() returns an instance of some class that was compiled against a different version of Hibernate.

0

精彩评论

暂无评论...
验证码 换一张
取 消