Closed islisava closed 5 years ago
Can't reproduce. What error do you get? What Lombok version?
I had the same problem. In Eclipse everything worked fine. But if i built with maven directly lombok completely (as if it was never executed, not even the other lombok annotations) as soon as I imported static from UtilityClasses. The only error given was something like
[ERROR] /D:/REDACTED/models/Dataset.java:[78,70] cannot find symbol
[ERROR] symbol: method getDirectory()
[ERROR] location: variable files of type REDACTED.DatasetFiles
The same missing symbol error repeated for each and every lombok generated method (e.g. getters and setters). As soon as I removed the static import everything worked fine again. I could reproduce the same problem with gradle+javac.
ps: Lombok 1.16.18, Java 1.8.0_131
Same is here.
OS: Windows 10 10.0
Lombok: 1.16.10
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
Always true with Lombok 1.16.20.
I have seen that this problem occurs if and only if :
So, as a workaround, you can explicitly declare your members static in the utility class, as follow:
@UtilityClass
public class TodayUtils {
public static LocalDateTime getTodayStartDay() {
return LocalDate.now().atStartOfDay();
}
}
Proceeding that way, you will be able to use static imports, as in :
import static packagename.TodayUtils.getTodayStartDay;
However, in this case, the only benefit of using @UtilityClass
is the generation of the constructor which avoids the instantiation of the class :-(
Got same issue when building with gradle 4.7 and Lombok 1.16.20
Same issue with lombok 1.18.0
+1
+1
This is a duplicate of many, many bug reports. However, lombok cannot fix this.
See: https://github.com/rzwitserloot/lombok/wiki/LOMBOK-CONCEPT:-Resolution https://stackoverflow.com/questions/47674264/static-import-not-working-in-lombok-builder-in-intellij
And a whole host of other bug reports, including: https://github.com/rzwitserloot/lombok/issues/884 https://github.com/rzwitserloot/lombok/issues/979
On Wed, Oct 10, 2018 at 1:25 PM hieutran notifications@github.com wrote:
+1
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rzwitserloot/lombok/issues/1382#issuecomment-428536217, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKCRboZUHtm_p4eFt322z-Ld5Wjv1IEks5ujdkggaJpZM4NX68v .
-- "Don't only practice your art, but force your way into it's secrets, for it and knowledge can raise men to the divine." -- Ludwig von Beethoven
Duplicate of #2044
For those who are still facing the issue, change your import with using star. It solved my problem.
import static packagename.TodayUtils.getTodayStartDay; -> import static packagename.TodayUtils.*;
Same issue with 1.18.30, using star static import works
Compilation fails when I try to use import static for @UtilityClass method Here is example.