This coming from a real world example, some Hibernate class subclasses an Antlr class and attempts to populate some field, which was only introduced in a recent Antlr version.
HibernateClass ---subclasses---> AntlrClass
HibernateClass uses AntlrClass.fieldX
If someone deploys at runtime an older Antlr library, this superclass field will not exist and a NoSuchFieldError will be thrown.
What is the standard Java/JVM way to make sure that the superclass you are dynamically binding to at runtime is a compatible version?
I’ll just give my own answer then —
Java was not designed to determine at run-time whether the compile-time super class matches/is compatible with the run-time super class. Since Java uses separate class paths for building vs. running, and since subclasses do not replicate contents from the superclass, NoSuchFieldErrors are expected.
Java does not handle this out of the box.