-
-
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] @UtilityClass fails to make inner class static in Java 9+ #3097
Comments
Heh, yeah that's no doubt what happened with #2519. Nice find. No need to test on the non-LTS versions except the last for such things. |
The generated code is fine but we also have to adjust the related compiler symbols, in this case we have to remove the enclosing type of the inner class. |
I think the first release containing this fix is version 1.18.24. |
I need this commit to make |
Describe the bug
When a class is annotated with
@UtilityClass
, and this class has an inner class, the inner class is also treated asstatic
in Java 1.8, but is not treated asstatic
in Java 9 and later. This causes compilation failure under Java 9+ for code that compiled correctly in Java 1.8.To Reproduce
Save the following as
Outer.java
:Compile this file using
javac
from Java 1.8, and observe that compilation succeeds with no diagnostic output:Now compile this file using
javac
from Java 9 or later, and observe that compilation fails:Expected behavior
Java 9 and later compilers should have compiled this source file, producing no diagnostic output.
Version info (please complete the following information):
javac
9Additional context
The problem first arises with Java 9, but also occurs in Java 11, 14, and 17. (I haven't tested Java 10, 12, 13, 15, or 16.)
#2519 seems closely related, but was closed because it could not be reproduced. However, that earlier report mentioned nothing about different Java versions. In this new report, I find that the Java compiler version is critical: the problem only arises in Java 9 and later, not in Java 1.8.
The text was updated successfully, but these errors were encountered: