-
Bug
-
Resolution: Fixed
-
P3
-
13, 21
-
b01
=== ./test/B.java
abstract class B extends A {}
=== ./test/A.java
import java.lang.annotation.ElementType;
import java.util.List;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
@interface TypeAnnotation {}
abstract class A implements List<@TypeAnnotation String> {}
=== ./plugin/p/P.java
package p;
import com.sun.source.util.JavacTask;
import com.sun.source.util.Plugin;
import com.sun.source.util.TaskEvent;
import com.sun.source.util.TaskListener;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
public class P implements Plugin {
@Override
public String getName() {
return "P";
}
@Override
public void init(JavacTask javacTask, String... strings) {
javacTask.addTaskListener(
new TaskListener() {
@Override
public void finished(TaskEvent e) {
if (e.getKind() != TaskEvent.Kind.ENTER) {
return;
}
TypeElement b = javacTask.getElements().getTypeElement("B");
for (TypeMirror i :
((TypeElement) ((DeclaredType) b.getSuperclass()).asElement()).getInterfaces()) {
System.err.printf("%s %s\n", i, i.getAnnotationMirrors());
}
}
});
}
}
=== ./plugin/module-info.java
module p {
requires transitive jdk.compiler;
provides com.sun.source.util.Plugin with p.P;
}
===
$ javac $(find plugin -name '*.java')
# when both compilation units are compiled from source, the type annotations are visible
$ javac --processor-module-path plugin -Xplugin:P test/A.java test/B.java
java.util.List<@TypeAnnotation java.lang.String>
java.util.List<@TypeAnnotation java.lang.String>
# when 'A' is loaded from the classpath, the type annotations on its supertype are not visible
$ javac --processor-module-path plugin -Xplugin:P -classpath test test/B.java
java.util.List<java.lang.String>
- causes
-
JDK-8359336 javac crashes with NPE while iterating params of MethodSymbol
-
- New
-
- clones
-
JDK-8225377 type annotations are not visible to javac plugins across compilation boundaries
-
- Resolved
-
- csr for
-
JDK-8346471 [REDO BACKPORT] type annotations are not visible to javac plugins across compilation boundaries
-
- Closed
-
- relates to
-
JDK-8354893 [REDO BACKPORT] javac crashes while adding type annotations to the return type of a constructor (JDK-8320001)
-
- Resolved
-
-
JDK-8337998 CompletionFailure in getEnclosingType attaching type annotations
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk21u-dev/42165463
-
Review(master) openjdk/jdk21u-dev/1251