[PATCH] JDK-8235457: Crash when reporting a message about an annotation on a module
Jeremy Kuhn
jeremy.kuhn.java at gmail.com
Fri Dec 6 23:36:34 UTC 2019
Hi,
Following previous discussions please find enclosed a patch for the issue
referenced in JDK-8235457.
The com.sun.tools.javac.model.JavacElements#matchAnnoToTree() method (line
275) is invoked when reporting a message on an annotation on an element to
return the tree for an annotation given the annotated element, this allows
the compiler to output the correct line where the message should be
displayed, however in the "Vis" class within the method the JCModuleDecl
has probably been forgotten when modules were introduced in JDK-9 leading
to an AssertionError crashing the compiler when an annotation processor
tries to report a message on a module's annotation.
In order to fix the issue, I've simply implemented the missing method
visitModuleDef() in the Vis class so that modules' annotations are properly
returned.
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 module's annotation
- mod: which contains a module annotated with the previous annotation
The test is successful when the test run without error and the message is
properly displayed 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20191207/6d6e850a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 8235457.patch
Type: text/x-patch
Size: 7749 bytes
Desc: not available
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20191207/6d6e850a/8235457.patch>
More information about the compiler-dev
mailing list