> Elements in a package are not considered included simply because a package-info file for that package was created.
However that doesn't match the behaviour we're seeing. Instead, getElementsAnnotatedWith is returning annotated members in a compilation with a package-info on the class path.
Reproduced using javac 9.0.1+11:
=== ./foo/A.java ===
package foo;
class A {
B b;
}
=== ./foo/B.java ===
package foo;
@Deprecated
class B {}
=== ./foo/package-info.java ===
@Deprecated
package foo;
=== ./P.java ===
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
@SupportedAnnotationTypes("*")
public class P extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
System.err.println(">>> " + roundEnv.getElementsAnnotatedWith(Deprecated.class));
return false;
}
}
===
$ javac P.java foo/B.java
$ javac -processor P -cp . -sourcepath : foo/A.java foo/package-info.java
...
>>> [foo, foo.B]
Note that getElementsAnnotatedWith returns foo.B, which is a member of the package foo, but which is not part of the current compilation.
- csr for
-
JDK-8208191 package-info handling in RoundEnvironment.getElementsAnnotatedWith
-
- Closed
-
- relates to
-
JDK-8213335 Don't soley rely on qualified name for annotation type identity in annotation processing
-
- Open
-
-
JDK-8208200 Add missing periods to sentences in RoundEnvironment specs
-
- Closed
-
-
JDK-8208371 Provided supported mechanims to create a ModuleElement for an unnamed module
-
- Resolved
-
-
JDK-8213103 RoundEnvironment.getElementsAnnotatedWith(Class) crashes with -source 8
-
- Resolved
-
-
JDK-8209865 Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
-
- Closed
-