I would like to generate warnings for ALL autoboxing and unboxing.
Has anyone found an effective way?
Eclipse catches basic autoboxing errors: eg. Integer i = null; i++
. But fails on anything complex, and isn't really what I'm after.
I've looked at PMD and Checkstyle but couldn't find anything there.
I know it's a controversial subject, but I think it's a dangerous feature. There's no way to disable it, so I would at least like a report to check during code reviews.
I see this NullPointerException
far too often in code reviews and bugs:
class X {
Integer i = null;
public int doSomething() {
return i + 2;
}
}
I want to stop it from getting that far.
Set this setting in your Eclipse,
Preferences -> Java -> Compiler -> Errors/Warnings -> Potential Programming Problems -> Boxing and unboxing conversions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With