Java 1.8 null annotations cause 'Contradictory null annotations' error [message #1287468] |
Mon, 07 April 2014 20:49 |
Tom van den Bege Messages: 9 Registered: July 2009 |
Junior Member |
|
|
I've installed the Kepler java 8 feature patch, and I'm using the latest null annotations jar (version 2.0.0, that came with the java 8 patch).
The following piece of code used to compile when my project was using Java 7, and the previous null annotations jar (1.1.0):
public static @NonNull <T> T assertNotNull(@Nullable T object) {
return assertNotNull(null, object);
}
public static @NonNull <T> T assertNotNull(@Nullable String message, @Nullable T object) {
if (object == null) {
throw new NullPointerException(message);
}
return object;
}
After upgrading the project to Java 8, and upgrading the null annotations jar to 2.0.0, the statement
return assertNotNull(null, object);
gives the following compiler error:
"Contradictory null annotations: method was inferred as '@NonNull @Nullable T assertNotNull(@Nullable String, @Nullable T)', but only one of '@NonNull' and '@Nullable' can be effective at any location "
If I replace the 2.0.0 jar with the 1.1.0 jar, it works again. This is not a solution however, since the old jar does not support type annotations.
Does anyone know why this doesn't compile?
Thanks,
Tom
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03860 seconds