Lombok: [BUG] Lombok v1.18.8 is not working with Eclipse 2019-06 release

Created on 27 Jun 2019  ·  19Comments  ·  Source: projectlombok/lombok

Describe the bug
Lombok is not working with Eclipse 2019-06 release

To Reproduce

  • Install Eclipse 2019-06 release
  • Install lombok v1.18.8 onto Eclipse
  • Create the Consumer.java class listed bellow
    => Internal compiler error: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.MethodBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.FieldBinding at org.eclipse.jdt.internal.compiler.ast.ASTNode.resolveAnnotations(ASTNode.java:840)

Expected behavior
Should compile

Version info (please complete the following information):

  • Lombok version v1.18.8
  • Platform Eclipse 2019-06.

Additional context
Consumer.java

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class Consumer {

    @JsonProperty("username")
    private String username;

    @JsonProperty("custom_id")
    private String customId;

    @JsonProperty("id")
    private String id;

    @JsonProperty("created_at")
    private String createdAt;

    @JsonProperty("tags")
    public String tags;
}

Most helpful comment

This seems to be an issue when Lombok is used with @JsonProperty in the same file. I can reproduce this in multiple Lombox and Eclipse versions. The only way I have found to get around this is to comment out the @JsonProperty, enable Build Automatically in Eclipse, let the build finish, and then uncomment the @JsonProperty.

All 19 comments

Cannot reproduce.

tried:

Result: absolutely no errors, everything works fine. Error log is empty. the getters and setters are there.

Clearly there's more going on (or possibly the master branch fixed it somehow but I doubt it; we didn't touch any code that would be related to any of this).

Please elaborate.

If no feedback after 2019-07-25, close issue.

@cmoine @olard @jordisilv if you can reproduce this, please tell us how.

@cmoine @Olard @jordisilv if you can reproduce this, please tell us how.

I faced problems using eclipse 2019-06 with JDK 1.8. No getters or setters were found after using "Data" annotation. No constructors created using e.g. "AllArgsConstructor" or "NoArgsConstructor" either.

I confirm the bug existence with JDK1.8 + Eclipse 2019-06. The project is unusable and I had to revert Lombok

I confirm the bug existence with JDK1.8 + Eclipse 2019-06. The project is unusable and I had to revert Lombok

So, is it working with a previous lombok versions (with JDK1.8 + Eclipse 2019-06)?
I reverted eclipse to 2018-12 since I thought the bug was related with latest eclipse.

@jordisilv Lombok v1.16.18 "Dancing Elephant" works with Eclipse 2019-06 + JDK1.8

@lrozenblyum using jdk 1.8.0_181 later upgraded to 1.8.0.221 and lombok 1.16.18 and eclipse 2019-06 it isn't working for me, tehre is simply no setter and getter created.

Sorry, coming back from holidays.

Test with Lombok 1.16.18 & Eclipse 2019-06 & JDK 1.8.0_201: works fine for me by rebuilding the project 👍

Lombok v1.18.6 works without any problem with Eclipse 2019-06 using JDK1.8

This seems to be an issue when Lombok is used with @JsonProperty in the same file. I can reproduce this in multiple Lombox and Eclipse versions. The only way I have found to get around this is to comment out the @JsonProperty, enable Build Automatically in Eclipse, let the build finish, and then uncomment the @JsonProperty.

This seems to be an issue when Lombok is used with @JsonProperty in the same file. I can reproduce this in multiple Lombox and Eclipse versions. The only way I have found to get around this is to comment out the @JsonProperty, enable Build Automatically in Eclipse, let the build finish, and then uncomment the @JsonProperty.

I was not using "@JsonProperty" when bug happened

Same here. Eclipse 2019-06 using jdk12 fails with lombok v1.18.6.
But works with lombok v1.16.18.

This seems to be an issue when Lombok is used with @JsonProperty in the same file. I can reproduce this in multiple Lombox and Eclipse versions. The only way I have found to get around this is to comment out the @JsonProperty, enable Build Automatically in Eclipse, let the build finish, and then uncomment the @JsonProperty.

Thanks for the Hint, I followed your steps, it worked, so I decided to updated my jackson to the latest version 2.9.9 and it worked, may not be a solotion to everyone, for those who can update jackson, it works.

This seems to be an issue when Lombok is used with @JsonProperty in the same file. I can reproduce this in multiple Lombox and Eclipse versions. The only way I have found to get around this is to comment out the @JsonProperty, enable Build Automatically in Eclipse, let the build finish, and then uncomment the @JsonProperty.

Thanks for the Hint, I followed your steps, it worked, so I decided to updated my jackson to the latest version 2.9.9 and it worked, may not be a solotion to everyone, for those who can update jackson, it works.

I updated to 2.9.9 and it is still occurring for me. I still have to comment out @JsonProperty, enable Build Automatically in Eclipse, let the build finish, and then uncomment the @JsonProperty.

I am currently running the following:

Lombox 1.18.8....tried 1.16.18 but still didn't work.
Jackson 2.9.9
Eclipse 2019-03
Jira 1.9

See also https://groups.google.com/forum/#!topic/project-lombok/0mvDpPmj6yc where this bug is being reported on the forums. I'm taking this off parked, but note that we still have no idea how to reproduce it locally. We do have a full stack trace to run with and some more hints as to how to try to reproduce this.

Here's the one thing that changed between 1.16.18 and now, for lombok at least: We have expanded the built-in list of 'copyable' annotations: Lombok will take any annotations that are on the copyable list (which is a built in list that you can add to via the lombok.config system), and will copy them to relevant locations: For example, if you @Setter a field that has a copyable annotation, we generate the setter so that the parameter of that setter also has the annotation. (copyability also has parameters; should the annotation be copied to the parameter, or the method itself? – I can't recall offhand how lombok solves that conundrum; we can't look at the annotation target definition because that would require resolution).

My theory is that lombok messes up this copying, creating an AST which is used for a while after lombok is done with it, and then later eclipse does resolution and creates bindings (but messes up due to the AST being not entirely conform eclipse's expectations), and then yet another eclipse internal process fails with a ClassCastEx. Which mostly means we've got some bug hunting to do especially if we still can't reproduce it!

Another theory is that as part of the 'copy this annotation from this location to that location' job, we copy over the binding, which in our experience is always null (because they haven't been created yet), but perhaps THAT is what's going wrong here: In your cases somehow due to some mix of plugins or whatnot, the binding HAS been calculated already, and we are copying it over which is no good because the binding inherently has the 'field' nature whereas we are copying it over to a method. Thus: a MethodBinding was created but some eclipse code was expecting it to be a FieldBinding.

TL;DR: Hey, we have ideas now and will try to find a way to fix it.

Be prepared for us to badger y'all with 'hey can you give this edge release a spin and see if you can trigger this bug with it?'

Good morning, for me works add next dependency

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-hateoas</artifactId>
    </dependency>

I had to turn off aspectj in project configuration to make it works fine to me.
Now its working with any version of Lombok, Eclipse Oxygen, OpenJDK 8, Spring Boot.

Fixed via ed3c8a67e2d757b0f15c5f2b53b7d6497f49db06

In my case the "Internal compiler error: java.lang.ClassCastException" came from a different version of lombok.jar - one was installed in the eclipse directory as javaagent and the second was in my maven project. After updating the lombok.jar in the eclipse directory anything works fine.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xiaolongzuo picture xiaolongzuo  ·  32Comments

eximius313 picture eximius313  ·  45Comments

lex-em picture lex-em  ·  61Comments

lombokissues picture lombokissues  ·  61Comments

kevcodez picture kevcodez  ·  58Comments