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
[CRASH] When @Getter(lazy = true) has Lambda in the initialization expression. #2300
Comments
If you have a PR, by all means. Including lambdas in that location is fairly exotic, I don't think this is a high priority fix. |
Suggested workaround, also works in some other similar scenario's: move the initializer code to a private static method: import lombok.Getter;
public class TestLombokBugLazyGetter {
public static String bar() { return ""; }
@Getter(lazy = true)
private final Object field = fooInitializer();
private static Object fooInitializer() {
return foo(bar(), null, () -> { });
}
public static Object foo(final Object arg0, final Object arg1, final Runnable arg3) { return null; }
} |
This is easy to fix, just let the |
And only when the initialization expression keeps the original position mark, the relevant behavior of Javac is correct. |
Oh, good one! |
When
Javac
tried toparse (attr)
theJCLambda
node in theLazyGetter Method Body
generated by@Getter(lazy = true)
, it crashed because thecache type
at thatlocation
did not match what wasexpected
.And in addition to crashing it can cause type inference to fail.
JDK: OpenJDK 13.0.1+9
Lombok: 1.18.11 (2019-09-26 08:56:18 UTC)
Reproduced by the following code:
Cause of error:
https://github.com/rzwitserloot/lombok/blob/a81df33c10f69d49425bdd0606052178a172a66f/src/core/lombok/javac/handlers/HandleGetter.java#L254-L255
This should not be done here.
com/sun/tools/javac/comp/ArgumentAttr.java
Maybe we should discuss this issue or I send a PR to fix it.
The text was updated successfully, but these errors were encountered: