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

@Builder annotation causes compile error with Java 11 #1907

Closed
jrmyr opened this issue Oct 16, 2018 · 9 comments
Closed

@Builder annotation causes compile error with Java 11 #1907

jrmyr opened this issue Oct 16, 2018 · 9 comments

Comments

@jrmyr
Copy link

jrmyr commented Oct 16, 2018

Hello!

My code using the @Builder annotation does not compile with Java 11 (or Java 10) while it compiles properly with Java 8.
As issue #1896 was closed and I could not reopen it, I create this issue to provide the code; please see here: https://github.com/jrmyr/lombokbuilder.

To reproduce the problem, just clone the repo and execute a simple gradle compileJava in it. Depending on the Java version in use, it will pass (8) or fail (10, 11). Tested on Mac.

Please tell me if you need more info.
Thanks.

@rspilker
Copy link
Collaborator

rspilker commented Oct 16, 2018

Can you try to assign the result of the build method to a local variable first?

@rspilker
Copy link
Collaborator

I don't know if we can configure the issue tracker to allow reopening by the reporter.

@rspilker
Copy link
Collaborator

I just found out that even the reporter cannot open an issues that they didn't close themselves.

@jrmyr
Copy link
Author

jrmyr commented Oct 17, 2018

I just found out that even the reporter cannot open an issues that they didn't close themselves.

No problem. Creating a new one and linking the old one is not an issue for me.

Can you try to assign the result of the build method to a local variable first?

I tried this but the behavior did not change. I updated the github repo with my changes.
Please tell me should I miss and/or misunderstand something.

@jrmyr
Copy link
Author

jrmyr commented Oct 17, 2018

It seems this issue is similar to #1877.
I checked with maven and with maven the project compiles under Java 8, 10 and 11.
So, seems gradle-specific.

EDIT: Sorry, I tried again with the project as a clean new maven project: I get the same error as well. So, maven is also affected and it's not gradle specific.
Sorry again for this misinformation and all this confusion.

@jrmyr jrmyr changed the title @Builder annotation causes compile error with Java 11 @Builder annotation causes compile error with Java 11 + gradle Oct 17, 2018
@jrmyr jrmyr changed the title @Builder annotation causes compile error with Java 11 + gradle @Builder annotation causes compile error with Java 11 Oct 17, 2018
@rzwitserloot
Copy link
Collaborator

rzwitserloot commented Oct 29, 2018

Here's a real simple test case for it:

class BuilderOnConstructor {
	@lombok.Builder
	BuilderOnConstructor(int a, boolean b) {}

	static class BuilderOnConstructorBuilder {
		void from() {
			a(x()).b(y());
		}
	}

	static int x() {
		return 0;
	}

	static boolean y() {
		return true;
	}
}

@rzwitserloot
Copy link
Collaborator

confirmed failure with error: BuilderOnConstructor.java:2: error: incompatible types: boolean cannot be converted to int on java9, 10, and 11. Not on 8.

@rzwitserloot
Copy link
Collaborator

NB: Just plain 'javac' is enough, you don't need gradle or maven to be involved. The chaining is key; if you write var x = a(x()); x.b(y()); it compiles fine.

@jrmyr
Copy link
Author

jrmyr commented Oct 30, 2018

Great! Thanks!

jrmyr added a commit to jrmyr/lombokbuilder that referenced this issue Oct 30, 2018
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

3 participants