projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.84k stars 2.38k forks source link

[BUG] @Synchronized causes error markers in Java editor with Eclipse 2024-09 (4.33.0) #3748

Open janrieke opened 1 week ago

janrieke commented 1 week ago

Describe the bug Since the update to Eclipse 2024-09 (4.33.0), classes that contain one or more @Synchronized annotations cause "CLASSNAME cannot be resolved to a type" errors in other classes that reference these classes.

Note that these errors only appear when the source file is actually opened in a Java editor. They neither show up in the Outline nor the Package Explorer. It seems they are just pseudo errors, because the compilation produces a valid class file and actually loading and executing the compiled classes also works.

Removing the @Synchronized makes the error disappear. Putting some other lombok annotations like @Builder or @EqualsAndHashCode on the (referenced) class also removes the error, while other annotations like @Getter or @ToString do not affect the error.

There is no error in the Eclipse logs when this problem is present.

To Reproduce Create a new Eclipse project with just these two files:

package test;
import lombok.Synchronized;

public class ClassWithSynchronized {
    @Synchronized
    public void test() {
    }
}

and

package test;

public class UsingClass {
    private ClassWithSynchronized test;
}

When opening UsingClass in the Java editor, you'll see an error marker at line 4 with the error message "ClassWithSynchronized cannot be resolved to a type".

Expected behavior No error markers present in referencing classes.

Version info (please complete the following information):

Rawi01 commented 1 week ago

Fixed our tests a few hours ago was able to write a test case to reproduce it using your example :+1:

janrieke commented 1 week ago

As a workaround you can try adding @EqualsAndHashCode to the referenced class to get rid of the error markers. You can remove @EqualsAndHashCode when you are finished editing a source file that references the problematic class, because the compilation still works.