projectlombok / lombok

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

[BUG] Annotation @UtilityClass don't working when using static import #3767

Open KovalevNikolay opened 3 hours ago

KovalevNikolay commented 3 hours ago

Annotation @UtilityClass don't working when using static import Screenshots default with using static import

To Reproduce Let's create a test class with a single VALUE field, specifying public final access modifiers for it. We will put the @UtilityClass annotation above the class, which will add the final access modifier to the class, the static access modifier to the field, and also create a private constructor.

Let's create a class with the Main method, where we will output the VALUE field from the previously created class to the console. When accessing it via ClassName.VALUE, the program runs without errors. Next, we will execute maven clean and instead of accessing the field by the name of the class, we will use static import. We launch the application and get an error:

java: cannot find symbol symbol: static VALUE location: class test.util.TestUtil

Version info (please complete the following information):

janrieke commented 3 hours ago

The documentation mentions this. Use a star import instead.