RFR: 8298065: Provide more information in message of NoSuchFieldError [v4]
David Holmes
dholmes at openjdk.org
Fri Dec 23 03:46:49 UTC 2022
On Thu, 22 Dec 2022 23:06:57 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> After this PR, if we output this:
>
> ```
> $ java -cp . Top
> Exception in thread "main" java.lang.NoSuchFieldError: Class Top does not have field 'int bar'
> at Top.main(top.jasm)
> ```
>
> I think this would be misleading. Top.java was written with the knowledge that "bar" is a field inherited from the "Base" class (**). During execution, "Base" is replaced by an incompatible version that no longer has such a field. However, the error message blames the "Top" class, even when the problem is in the "Base" class.
I didn't read "have field bar" as meaning has the direct member field bar, but if you are concerned about that then a simple change is:
"Class Top does not have, or inherit, field 'int bar'"
or more succinctly:
"Class Top does not have a member field 'int bar'"
-------------
PR: https://git.openjdk.org/jdk/pull/11745
More information about the hotspot-runtime-dev
mailing list