Skip to content
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] delombok code using java 11 var keyword recognized as lombok var, using maven delombok plugin #2049

Closed
gavocanov opened this issue Feb 24, 2019 · 2 comments

Comments

@gavocanov
Copy link

Hi,

I'v been trying to use the maven delombok plugin for a project using Java 11 var keyword, delombok generated code like

/*missing*/ grouped = blabla.get(id);

I posted an issue in the maven plugin repository but was directed here.

@rzwitserloot
Copy link
Collaborator

That actually means there's a bug in your code and there's nothing we can do about it. Possibly you're running delombok such that the javac that's used to delombok your stuff is from pre-10. That /* missing */ isn't something we generate directly; it means the vartype field of the JCVariableDecl node is null.

You can reproduce this by trying to delombok the following in java 11:

import lombok.var; // generates an error. We want this for this test.
class Example { public void test() {
    var x = 10; // this will turn into /* missing */
}}

But that makes 'sense' so to speak, because var in this case neither means the keyword nor the lombok type, in a certain frame of thinking (not the most sane frame, but it's what javac11 does).

But, if you remove the error and try this, in java11:

class Example { public void test() {
    var x = 10;
}}

The only way to know it was a 'var' in the original source file when errors occur is if the vartype variable is null, and otherwise, if the position of the var node is -1, which feels utterly finicky, but, hey, javac's own Attr class pulls the same crazy stunt, so, I guess ¯_(ツ)_/¯

so that's what we did. From the next release on delombok will delombok 'var' right.. though it might delombok various errors into var as well. javac authors, if you read this: Next time, just find an unused bits in the flags variable please :)

@gavocanov
Copy link
Author

I see, in my setup (both gradle and maven) I use kapt to trigger all annotation processing, and since kotlin supports only java 1.6/1.8 I suppose javac11 is set by kapt to source code level 8 and causing those issues.

Thnx for the explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants