Relaxing annotation based null checks on JDK8 [message #1695721] |
Mon, 18 May 2015 11:39  |
Eclipse User |
|
|
|
Hi,
I'm in the process of upgrading my code base to use JDK8 and I'm stumbling over the stricter annotation based null checking that requires me to annotate generic types with @Nullable/@NonNull.
The JDK7 approach allowed me to selectively add @Nullable/@NonNull on methods. The JDK8 annotations require me to annotate generic types, causing tons of errors in my code base. Example:
class Foo<T> exends Object
{
public T bar()
{
return null;
}
}
I understand why the new analysis marks the return null statement an error but if I change the declaration of the class to Foo<@Nullable T> all the client code that uses Foo will contain errors.
I do understand the why the new strictness is required. It's clearly my codebase's fault to not properly check the type bounds but alas, I have a lot of code that I cannot and do not want to change right now.
Is there any possibility to get the old, relaxed @Nullable/@NonNull checks on JDK8? (Hint: just using the JDK7 compatible annotations does not work ....).
-dirk
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02905 seconds