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

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


Hello,

> 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 !=
null)
                sourceFile = existingPackage.package_info.sourcefile;
or:

--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java
@@ -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?

Thanks,
Liam

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

> PS Filed
>
>     JDK-8193462: Fix Filer handling of package-info initial elements
>
> The not-quite-working version of the fix is at:
>
>     http://cr.openjdk.java.net/~darcy/8193462.0/
>
> -Joe
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20171213/b457c62f/attachment.html>


More information about the compiler-dev mailing list