RFR: JDK-8042981: Strip type annotations in Types' utility methods [v2]
Jan Lahoda
jlahoda at openjdk.org
Wed Sep 21 11:32:52 UTC 2022
On Sun, 26 Jun 2022 22:52:43 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.
>
> Joe Darcy has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>
> - Update visitor; all langtools regression tests pass.
> - Merge branch 'master' into JDK-8042981
> - JDK-8042981: Strip type annotations in Types' utility methods
src/java.compiler/share/classes/javax/lang/model/util/Types.java line 241:
> 239: * @param extendsBound the extends (upper) bound, or {@code null} if none
> 240: * @param superBound the super (lower) bound, or {@code null} if none
> 241: * @throws IllegalArgumentException if bounds are not valid
Should annotation also be preserved (and also documented to be preserved) for `getDeclaredType`?
test/langtools/tools/javac/processing/model/util/types/TestAnnotationStripping.java line 137:
> 135: // public static @TypeAnnotation("foo4") java.util.Set foo4() {return null;}
> 136:
> 137: // public static @TypeAnnotation("foo4") String[] foo4() {return null;}
It would be good to have a test verifying the annotation on the array component is removed by `erasure`.
-------------
PR: https://git.openjdk.org/jdk/pull/8984
More information about the compiler-dev
mailing list