RFR: JDK-8042981: Strip type annotations in Types' utility methods
Srikanth Adayapalam
sadayapalam at openjdk.org
Fri Jun 24 08:03:08 UTC 2022
On Thu, 2 Jun 2022 01:09:17 GMT, Joe Darcy <darcy at openjdk.org> wrote:
> Early review for JDK-8042981: "Strip type annotations in Types' utility methods". I work more often in the Element world rather than the Type word of the annotation processing APIs.
>
> The type annotations on primitive types are *not* cleared by the existing annotation clearing mechanisms. I suspect Type.Visitor is missing a case for primitive types. Someone with familiarity with javac's type modeling should take a look; thanks.
Also it occurs to me that there is inconsistency in com.sun.tools.javac.model.JavacTypes#erasure (implementing javax.lang.model.util.Types#erasure) stripping the type annotations
(See https://mail.openjdk.org/pipermail/compiler-dev/2014-May/008792.html where Alex makes the comment:
For example, if I have a TypeMirror that
represents '@Foo List<String\>', and I pass it to the erasure method,
then I could reasonably expect to get back a TypeMirror that represents
'@Foo List'. Similarly for getArrayType, getDeclaredType, etc."
)
while javax.lang.model.util.Types#getArrayType preserving the annotations.
But I think this behavior is too entrenched to do much about it - the new comments calling out the cases where the annotations are preserved, it would appear are documenting current behavior expressly and so OK.
-------------
PR: https://git.openjdk.org/jdk/pull/8984
More information about the compiler-dev
mailing list