RFR: 8298065: Provide more information in message of NoSuchFieldError
Matias Saavedra Silva
matsaave at openjdk.org
Tue Dec 20 23:04:30 UTC 2022
A java.lang.NoSuchFieldError is typically thrown when you remove a field but do not recompile the client code that calls the field. However, the message does not indicate in which class the field was not found.
Additionally, java.lang.NoSuchFieldError is thrown if the field is still present but the types are incompatible. For example, if a field is first defined as int, and later changed to long without recompiling the client. The error text has been expanded to include the class name and field type. Verified with tier 1 tests.
Old output:
`Exception in thread "main" java.lang.NoSuchFieldError: x
at NoSuchFieldMain.main(NoSuchFieldMain.java:3)`
Example output:
`Exception in thread "main" java.lang.NoSuchFieldError: Class Other does not have field 'int x'
at NoSuchFieldMain.main(NoSuchFieldMain.java:3)`
-------------
Commit messages:
- Merge branch 'master' into noSuchFieldError_8298065
- 8298065: Provide more information in message of NoSuchFieldError
Changes: https://git.openjdk.org/jdk/pull/11745/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11745&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8298065
Stats: 152 lines in 5 files changed: 150 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/11745.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/11745/head:pull/11745
PR: https://git.openjdk.org/jdk/pull/11745
More information about the hotspot-runtime-dev
mailing list