RFR: 8332497: javac crashes when annotation processing runs on program with module imports [v4]
Jan Lahoda
jlahoda at openjdk.org
Mon May 20 07:41:01 UTC 2024
On Mon, 20 May 2024 07:30:35 GMT, Evemose <duke at openjdk.org> wrote:
>> Fix is pretty simple: visitModuleImport in com.sun.tools.javac.tree.TreeScanner has notbeen overriden, so defaulted to Visitor::visitModuleImport, which forwards to Visitor::visitTree, which is also not overriden, and, therefore, threw AssertionError.
>>
>> PS: Im not even sure how it worked before without crashing, seems like there is some intermidiate implementation between this TreeScanner and actual scanners because otherwise it should have resultedin compile error the moment it encounter module importin any visitor
>
> Evemose has updated the pull request incrementally with one additional commit since the last revision:
>
> Added getSupportedSourceVersion() to AP
The test is not wrong, but could be made shorter like here:
https://github.com/lahodaj/jdk/blob/8e4c9f4091f443766e5f009317661260154a33a8/test/langtools/tools/javac/ImportModule.java#L750
Also, the similar `com.sun.tools.javac.tree.TreeTranslator` could also be made consistent and handle module imports. Although I doubt there is an end-user way to see the difference (I am not aware about any whole-AST translation in javac; only per-class translations; for the internal scanner, it is also more common to scan only classes, I think).
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19292#issuecomment-2119857759
More information about the compiler-dev
mailing list