-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
static import on @Getter field breaks compilation #1421
Comments
It does. https://projectlombok.org/features/GetterSetter (emphasis mine)
|
It should, but it's not.
Let me put more details:
pom.xml
|
When I remove static, then everything fine.
|
You can annotate the static field directly. So instead of this: @Getter
public class MyTest {
private static int x;
public static void foo() {
MyTest.getX();
}
} You should write this: public class MyTest {
@Getter
private static int x;
public static void foo() {
MyTest.getX();
}
} The You could argue that annotating every static field is cumbersome and that some solution should be addressed. But, in my personal opinion and experience, the developer rarely would like to add a bunch of getters en mass to static fields, (s)he whould want to do that only to instance fields. So, I think that the current behaviour makes perfect sense for now. Another possibility would be to suggest something like |
Thanks for explanation, makes sense.
And because of this static import, all lombok code generation fails, even if I'm using log.error("smth") with @slf4j I got that log can't be found, that's why it was hard to find the exact problem I had in my project, which I didn't cover in the previous examples. |
That issue with static imports seems to be indeed a bug. I was able to reproduce it. |
Can I somehow enable (and if I can, I think it should be enabled by default) Lombok's debug / error messages during compilation for things like that ? |
As @Maaartinus said lombok does not generate getters for static fields if you put |
Add the related lombok dependencies in gradle file, resolved the issue Step2 Step3 |
any chance this will be fixed? |
Hi,
@getter is not working on static fields - compilation error.
I'm using lombok 1.16.10 and java 1.8.0_131.
Example:
The text was updated successfully, but these errors were encountered: