RFR: 8284315: DocTrees.getElement is inconsistent with Elements.getTypeElement [v2]
Hannes Wallnöfer
hannesw at openjdk.org
Thu Feb 26 17:49:20 UTC 2026
> Please review a change that brings the implementation of `DocTrees.getElement(DocTreePath)` in agreement with `javax.lang.model` behavior by returning `null` for `DocTree` instances referring to a primitive or array type. Additionally, this adds some missing functionality to the implementation of the related `DocTrees.getType(DocTreePath)` method and improves test coverage for both methods.
>
> Internally, the member lookup part in method `JavacTrees.attributeDocReference` is split into a separate `resolveMember` method that can also be used by `getType`.
>
> We also improve attribution of references with explicit module name by attempting to attribute the referenced type and checking whether the module matches the name in the reference afterwards. This allows us to support parameterized types in references with explicit module id.
>
> In `test/langtools/tools/javac/doctree/ReferenceTest.java` we add some missing test coverage such as for type parameter references, and add tests for `DocTrees.getType(DocTreePath)` to the existing tests for `DocTrees.getElement(DocTreePath)`. The former was previously ony covered in javadoc tests.
Hannes Wallnöfer has updated the pull request incrementally with one additional commit since the last revision:
Address review feedback
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/29547/files
- new: https://git.openjdk.org/jdk/pull/29547/files/474afb97..b2d792d8
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=29547&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=29547&range=00-01
Stats: 8 lines in 2 files changed: 6 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/29547.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29547/head:pull/29547
PR: https://git.openjdk.org/jdk/pull/29547
More information about the javadoc-dev
mailing list