Integrated: 8298065: Provide more information in message of NoSuchFieldError
Matias Saavedra Silva
matsaave at openjdk.org
Wed Jan 11 19:16:34 UTC 2023
On Tue, 20 Dec 2022 22:55:59 GMT, Matias Saavedra Silva <matsaave at openjdk.org> wrote:
> 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-4 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)`
>
> The added test considers different types of fields like primitives, arrays, and references.
This pull request has now been integrated.
Changeset: 43847c43
Author: Matias Saavedra Silva <matsaave at openjdk.org>
Committer: Coleen Phillimore <coleenp at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/43847c43ad2e84999554468f79016dd33528ec14
Stats: 357 lines in 9 files changed: 354 ins; 0 del; 3 mod
8298065: Provide more information in message of NoSuchFieldError
Reviewed-by: dholmes, iklam, coleenp
-------------
PR: https://git.openjdk.org/jdk/pull/11745
More information about the hotspot-runtime-dev
mailing list