RFR: 8305971: NPE in JavacProcessingEnvironment for missing enum constructor body
Joe Darcy
darcy at openjdk.org
Thu Sep 28 23:02:28 UTC 2023
On Thu, 28 Sep 2023 21:23:54 GMT, Vicente Romero <vromero at openjdk.org> wrote:
> Please review this simple fix that is averting a NPE in JavacProcessingEnvironment if a an annotation processor is used while compiling this erroneous code:
>
>
> enum T {
> ONE("");
>
> T(String one); // missing constructor body
>
> final String one;
> }
>
> the fix is a one liner
> TIA
Is this issue or an analagous issue triggered for default constructors or the special constructors of records?
Is so, it would be good to have explicit test coverage of those cases too.
test/langtools/tools/javac/annotations/crash_empty_enum_const/SimpleProcessor.java line 31:
> 29: import javax.lang.model.element.TypeElement;
> 30:
> 31: @SupportedAnnotationTypes("*")
The style of annotation processor tests does vary a bit by area of javac. It should be technically possible to put the code being tested and the annotation processor into a single file, as is commonly done in the direct annotation processing tests.
I can send some pointers if that kind of refactoring would be of interest.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15974#issuecomment-1740100749
PR Review Comment: https://git.openjdk.org/jdk/pull/15974#discussion_r1340733722
More information about the compiler-dev
mailing list