Do package-infos need to be reset between annotation processing rounds?

Liam Miller-Cushon cushon at
Thu Dec 14 01:03:27 UTC 2017


> the sourcefile field of the PackageSymbol doesn't seem to be getting set
to a non-null value via the lookup process. I didn't fully run down which
part of JavacElements or Symbol takes care of that.

It looks like PackageSymbol.sourcefile is only initialized by
JavadocClassFinder. PackageSymbol.package_info.sourcefile does get set up
correctly in Enter, so using `existingPackage.package_info.sourcefile` (or
setting the PackageSymbol's sourcefile in Enter at the same time as
package_info) allows the test to pass, i.e.:

    private boolean containedInInitialInputs(String typename) {
            if (existingPackage != null && existingPackage.package_info !=
                sourceFile = existingPackage.package_info.sourcefile;

--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/
@@ -379,6 +379,7 @@
             c.completer = Completer.NULL_COMPLETER;
                 c.members_field = WriteableScope.create(c);
                 tree.packge.package_info = c;
+                tree.packge.sourcefile = tree.sourcefile;

And to check my understanding: the issue you discovered is separate from
both JDK-8193037 and JDK-8193216, right? Does my diagnosis of JDK-8193037
sound reasonable? And for JDK-8193216, do you think it makes sense to
consider warning in that case, even if it isn't required by the spec?


On Wed, Dec 13, 2017 at 1:51 PM, joe darcy <joe.darcy at> wrote:

> PS Filed
>     JDK-8193462: Fix Filer handling of package-info initial elements
> The not-quite-working version of the fix is at:
> -Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list