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
@Getter(lazy=true) causes unchecked cast warning #880
Comments
There's not a lot we can do here. We do put two annotations on the method to let the compiler know it shouldn't emit warnings:
The code is fine. Yes, the cast might be unsafe, but the code makes sure it isn't. |
Is SuppressWarnings definitely being added correctly? I'm |
For what it's worth, here's the workaround we settled on, which gets rid of the warnings.
|
@rspilker According to the duplicate thread, adding the "unchecked" token to "all" helps, and it should be rather easy for Lombok to do this. Should I give it a try? Or would you? There's a minor complication: For primitives, the "unchecked" token produces a warning in eclipse. |
@rspilker One wrinkle that makes this a bit more problematic: the |
Just to get it on the record: Whomever designed how Adding "unchecked" helps, yeah. We'll get on that; good point by @Maaartinus that we do need to check if the type is primitive in which case, don't (we already do this, I think; we have to use a different AtomicX if the field is primitive already, and whilst we can't do resolution, primitives are hardcoded concepts we can trivially check for – not complicated in either case). |
Can't reproduce. We actually cast e.g. |
Live in 1.18.12. |
The Lombok-generated code from @getter(lazy=true) contains a cast from Object to the field's type, which causes an unchecked cast warning when compiling with -Xlint:all.
The text was updated successfully, but these errors were encountered: