You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When defining a nested class inside a class annotated with @UtilityClass fails when the nested class is annotated with @Builder. The compiler (javac) reports the following error, with no file or line information:
error: modifier static not allowed here
This only seems to be failing using JDK8. I tried JDK17 an couldn't reproduce. It also happens only with direct Lombok code generation. Executing delombok and then compiling the result works.
To Reproduce
Try to build the following code with a Java 8 compiler:
Executing delombok (with the same JDK version) also prints the error message mentioned above, but still manages to print the following code:
// Generated by delombok at Thu Sep 07 11:59:34 CEST 2023publicfinalclassSample1 {
publicstaticclassNested {
privateintx;
@java.lang.SuppressWarnings("all")
Nested(finalintx) {
this.x = x;
}
@java.lang.SuppressWarnings("all")
publicstaticclassNestedBuilder {
@java.lang.SuppressWarnings("all")
privateintx;
@java.lang.SuppressWarnings("all")
NestedBuilder() {
}
/** * @return {@code this}. */@java.lang.SuppressWarnings("all")
publicSample1.Nested.NestedBuilderx(finalintx) {
this.x = x;
returnthis;
}
@java.lang.SuppressWarnings("all")
publicSample1.Nestedbuild() {
returnnewSample1.Nested(this.x);
}
@java.lang.Override@java.lang.SuppressWarnings("all")
publicjava.lang.StringtoString() {
return"Sample1.Nested.NestedBuilder(x=" + this.x + ")";
}
}
@java.lang.SuppressWarnings("all")
publicstaticSample1.Nested.NestedBuilderbuilder() {
returnnewSample1.Nested.NestedBuilder();
}
}
@java.lang.SuppressWarnings("all")
privateSample1() {
thrownewjava.lang.UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}
And this code does compile correctly.
Expected behavior
Since JDK 17 and delomboking works. The expected behavior is the compilation to work in Java 8.
Version info (please complete the following information):
Lombok version: 1.18.26
Platform: Amazon Corretto
javac 1.8.0_372 (fails)
javac 17.0.7 (works)
Additional context
I believe since Java 8 is nearing it's end of life, this will be considered low priority. Still, I thought it could at least document one failing corner case for other potential developers facing the same issue.
The text was updated successfully, but these errors were encountered:
Describe the bug
When defining a nested class inside a class annotated with
@UtilityClass
fails when the nested class is annotated with@Builder
. The compiler (javac
) reports the following error, with no file or line information:This only seems to be failing using JDK8. I tried JDK17 an couldn't reproduce. It also happens only with direct Lombok code generation. Executing delombok and then compiling the result works.
To Reproduce
Try to build the following code with a Java 8 compiler:
Executing delombok (with the same JDK version) also prints the error message mentioned above, but still manages to print the following code:
And this code does compile correctly.
Expected behavior
Since JDK 17 and delomboking works. The expected behavior is the compilation to work in Java 8.
Version info (please complete the following information):
javac 1.8.0_372
(fails)javac 17.0.7
(works)Additional context
I believe since Java 8 is nearing it's end of life, this will be considered low priority. Still, I thought it could at least document one failing corner case for other potential developers facing the same issue.
The text was updated successfully, but these errors were encountered: