Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Eclipse handlers don't support enum constants #3427

Closed
vladtimofeev000 opened this issue May 19, 2023 · 3 comments · Fixed by #3494
Closed

[BUG] Eclipse handlers don't support enum constants #3427

vladtimofeev000 opened this issue May 19, 2023 · 3 comments · Fixed by #3494
Milestone

Comments

@vladtimofeev000
Copy link

vladtimofeev000 commented May 19, 2023

Describe the bug
For enum constants JDT leaves null TypeReference in org.eclipse.jdt.internal.compiler.ast.FieldDeclaration, but lombok.eclipse.handlers.HandleGetter doesn't ready for it so there will be several problems:

  1. NPE at isBoolean
  2. Null return type at createGetter so it will be generated as void method
  3. Not static modifier

Looks like It can be reproduced with other annotation handlers.

To Reproduce
Case:

public enum EnumTest {
    @Getter
    AAA
}

Result:

Lombok annotation handler class lombok.eclipse.handlers.HandleGetter failed
java.lang.NullPointerException
at lombok.eclipse.handlers.EclipseHandlerUtil.isBoolean(EclipseHandlerUtil.java:1425)
at lombok.eclipse.handlers.HandleGetter.createGetterForField(HandleGetter.java:193)
at lombok.eclipse.handlers.HandleGetter.createGetterForFields(HandleGetter.java:164)
at lombok.eclipse.handlers.HandleGetter.handle(HandleGetter.java:153)
at lombok.eclipse.HandlerLibrary$AnnotationHandlerContainer.handle(HandlerLibrary.java:106)
at lombok.eclipse.HandlerLibrary.handleAnnotation(HandlerLibrary.java:237)
at lombok.eclipse.TransformEclipseAST$AnnotationVisitor.visitAnnotationOnField(TransformEclipseAST.java:245)
at lombok.eclipse.EclipseNode.traverse(EclipseNode.java:110)

Expected behavior
Javac handler works well in this case and generate method:

public static EnumTest getAAA() {
    return AAA;
}

Version info:
Platform Eclipse:

  • Version: 2023-03 (4.27.0)
  • Build id: 20230309-1520
  • Lombok v1.18.26 "Envious Ferret" is installed
@vladtimofeev000 vladtimofeev000 changed the title [BUG] Eclipse HandleGetter doesn't support enum constants [BUG] Eclipse handlers doesn't support enum constants May 19, 2023
@vladtimofeev000 vladtimofeev000 changed the title [BUG] Eclipse handlers doesn't support enum constants [BUG] Eclipse handlers don't support enum constants May 19, 2023
@ZeYuYang1024
Copy link

you might have to create the getter methods manually for each enum constant.

@Rawi01
Copy link
Collaborator

Rawi01 commented May 22, 2023

Obviously lombok should not fail with an NPE and it is not that difficult to fix this but I don't get why you need a getter for an enum constant. It might be better to also remove the javac support for this.

@vladtimofeev000
Copy link
Author

@Rawi01 ,

I don't get why you need a getter for an enum constant

Me too. I just want to sync eclipse and javac behaviors. Prevent NPE and remove the 'javac' support - will be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants