Reputation: 597116
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)
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?
Upvotes: 2
Views: 4848
Reputation: 597116
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.
Upvotes: 4
Reputation: 234797
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
.
Upvotes: 1