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?
Joshua Bloch explained this in his short presentation –
static finalfields are copied into the client library, so it should be recompiled when a constant changes.