JDK-8346199 : Clean up use of javax.lang.model.element API in javadoc
  • Type: Task
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2024-12-13
  • Updated: 2025-03-26
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 26
26Unresolved
Related Reports
Relates :  
Relates :  
Relates :  
Description
JavaDoc use of the javax.lang.model.element API is somewhat spoiled by the implementation of that API in OpenJDK, which allows to take shortcuts such as comparing objects by reference and determining element kind using the instanceof operator. These are not guaranteed to work by the API itself[1].

Although javadoc is developed and ships with the OpenJDK implementation of the Element API, it would be good to change the code to use the supported idioms such as `equals`, `getKind` and visitors.

[1]: https://docs.oracle.com/en/java/javase/23/docs/api/java.compiler/javax/lang/model/element/Element.html
Comments
Yes, as done several times before, if there is useful functionality needed by javadoc missing from javax.lang.model, it is reasonable to add it to the supported feature set of that API.
13-12-2024

As a follow up, while I believe `javadoc` will always be tied to JDK because of the dependence on javac, I endorse the goal to clean up the use of the Language Model API where possible.
13-12-2024

Related: address the related issues in the Language Model API that necessitate the use of the `WorkArounds` class in `javadoc`. Note that while it may be possible to make the standard docket be "clean" with regards to the Language Model API, the front end of the tool is inherently tied to JDK/javac.
13-12-2024