Integrated: 8371960: Missing null check in AnnotatedType annotation accessor methods
Chen Liang
liach at openjdk.org
Tue Nov 18 15:16:53 UTC 2025
On Sun, 16 Nov 2025 16:02:58 GMT, Chen Liang <liach at openjdk.org> wrote:
> `AnnotatedElement` methods specify they throw NPE if they take any null argument: `isAnnotationPresent`, `get(Declared)Annotation`, `get(Declared)AnnnotationsByType`. However, `AnnotatedType` has implementation quality issues that it does not throw NPE for `isAnnotationPresent` and `get(Declared)Annotation`.
>
> This patch fixes this oversight by adding explicit null checks. For `get(Declared)AnnotationsByType`, even though it did throw exceptions, it was in the middle of parsing, so throwing it in the beginning is better.
This pull request has now been integrated.
Changeset: b6d83eda
Author: Chen Liang <liach at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/b6d83eda6bfa76da98274aa3ad294759cb56d3a5
Stats: 105 lines in 2 files changed: 103 ins; 0 del; 2 mod
8371960: Missing null check in AnnotatedType annotation accessor methods
Reviewed-by: alanb
-------------
PR: https://git.openjdk.org/jdk/pull/28341
More information about the core-libs-dev
mailing list