[PATCH] JDK-8235458: Problem caused by imports in a module-info.java file
Jonathan Gibbons
jonathan.gibbons at oracle.com
Sat Dec 7 01:00:39 UTC 2019
On 12/06/2019 03:53 PM, Jeremy Kuhn wrote:
> Hi,
>
> Following previous discussions please find enclosed a patch for the
> issue referenced in JDK-8235458.
>
> When the compiler initiates the annotation processing environment it
> scans all compilation units to discover whether there are some with
> annotations to process and create the first round of annotation
> processing. This is done in the JavacProcessingEnvironment (line 1090
> in the Round constructor), module info files are filtered within the
> getModuleInfoFiles() method (line 1515) but this method currently
> assumes a module info files always starts with a module declaration
> even though import statements can be present first according to the
> Java language specification as a result an annotated module with
> import statements is ignored during annotation processing.
>
> In order to fix the issue, I've had to loop over the unit defs to
> ignore any import statements until I found either a module tag in
> which case I can include the module in the list of modules info files
> to process or any other tag in which case I ignore the unit which is
> not a module.
>
> You'll find a jtreg test in the patch as well, I've actually created
> three modules for the test:
> - annotation: which defines a simple module annotation
> - processor: which provides the annotation processor reporting a
> message on the annotated module
> - mod: which contains a module annotated with the previous annotation
> with import statements
>
> The test is successful when the it runs without errors and the
> annotation is properly processed by the compiler.
>
> I didn't find a way to use jtreg tags to compile modules, so I've
> decided to compile everything programmatically in the test main() method.
>
> Please let me know if I can be of any further assistance.
Hi Jeremy,
Thanks for providing the patch for the second of your issues. I've
uploaded the patch as a webrev:
http://cr.openjdk.java.net/~jjg/8235458/webrev/index.html
The fix for JavacProcessingEnvironment looks OK, but as for the test,
isn't this the same test from
the other fix?
-- Jon
More information about the compiler-dev
mailing list