RFR: 8320001: javac crashes while adding type annotations to constructor's return type
Liam Miller-Cushon
cushon at openjdk.org
Tue Nov 21 23:34:12 UTC 2023
On Tue, 21 Nov 2023 23:22:47 GMT, Vicente Romero <vromero at openjdk.org> wrote:
>> test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnosOnConstructorsTest.java line 119:
>>
>>> 117: .classpath(classes, classDir)
>>> 118: .options("-processor", SimpleProcessor.class.getName())
>>> 119: .files(yWrapper)
>>
>> It should be equivalent to use `.classes("Y")` to request annotation processing of `Y` directly, and avoid the need for `YWrapper`. But either way is fine.
>
> thanks for your comment, yes I tried that but all of the APIs we offer in JavacTasks were failing stating that the file was not a source file, this is why I decided to use a wrapper
That's weird, I tried it out before commenting and it worked for me, I was able to reproduce the crash and then see the test pass with the fix using:
diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnosOnConstructorsTest.java b/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnosOnConstructorsTest.java
index 50c596ac79b..49f694a9a4f 100644
--- a/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnosOnConstructorsTest.java
+++ b/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnosOnConstructorsTest.java
@@ -98,12 +98,6 @@ class Y {
@Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
@interface TA {}
- """,
- """
- class YWrapper {
- // just to make the compiler load the class file for class Y above
- Y y;
- }
""");
// we need to compile Y first
@@ -116,7 +110,7 @@ class YWrapper {
new JavacTask(tb)
.classpath(classes, classDir)
.options("-processor", SimpleProcessor.class.getName())
- .files(yWrapper)
+ .classes("Y")
.outdir(classes)
.run(Task.Expect.SUCCESS);
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16774#discussion_r1401331846
More information about the compiler-dev
mailing list