JDK-8245620 : Improve Annotation.annotationType() documentation
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 14
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2020-05-18
  • Updated: 2020-07-02
  • Resolved: 2020-06-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 16
16Fixed
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
It appears for a java.lang.annotation.Annotation x, one is supposed to call x.annotationType() instead of x.getClass().
However, currently this is not obvious from the Annotation documentation, neither are the reasons for this explained.

Expected would be that:
1. The class documentation of Annotation mentioned that one should prefer annotationType() to getClass()
2. The annotationType() doc explained why this method should be preferred to calling getClass()



Comments
Changeset: b81f2f1f Author: Joe Darcy <darcy@openjdk.org> Date: 2020-06-11 15:55:19 +0000 URL: https://git.openjdk.java.net/lanai/commit/b81f2f1f
02-07-2020

Changeset: b81f2f1f Author: Joe Darcy <darcy@openjdk.org> Date: 2020-06-11 15:55:19 +0000 URL: https://git.openjdk.java.net/amber/commit/b81f2f1f
02-07-2020

Fixed in JDK 16.
12-06-2020

Review thread: https://mail.openjdk.java.net/pipermail/core-libs-dev/2020-June/067173.html
11-06-2020

Javadoc of annotationType() is at https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/annotation/Annotation.html#annotationType()
22-05-2020