-
-
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
[BUG] "value" field in init expression of @Getter(lazy=true) not working #2917
Comments
While in theory we can do some fancy footwork and notice that this is happening and inject a |
My plan was to keep using |
Why not just always prefix the field with "this." at the corresponding places? This should avoid name conflicts in all cases, or doesn't it? Or can |
Yes, |
This is part of the latest edge release, all feedback is welcome. |
This code:
will rise exception through compile time:
..., but if we just RENAME field variable "value" to whatever else - "val", for example - it compiles and executes successfully!
The reason is...
this class will delomboked to this:
I.e., when we try to use "value", it conflicts with local variable - "value", used in code, generated by Lombok (and has a type java.lang.Object and actually has not "length()" method, that's why we had an error message above).
So, I think, the problem is that LOCAL VARIABLE in method, generated by Lombok for
@Getter(lazy = true)
, was not named so well...This name - "value" - is used very often for field, so I think this bug is important to fix.
Possible solution
I think, there is 2 variants:
$_$321_IT_WILL_NEVER_USED_BY_ANYONE_123_$_$
, for example...Version info:
$ java -version
output:openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment Corretto-16.0.2.7.1 (build 16.0.2+7)
OpenJDK 64-Bit Server VM Corretto-16.0.2.7.1 (build 16.0.2+7, mixed mode, sharing)
The text was updated successfully, but these errors were encountered: