Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Java 1.8 null annotations cause 'Contradictory null annotations' error(Upgrading from null annotations 1.1.0 to 2.0.0 results in compilation errors)
Java 1.8 null annotations cause 'Contradictory null annotations' error [message #1287468] Mon, 07 April 2014 20:49 Go to next message
Tom van den Bege is currently offline Tom van den BegeFriend
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
Re: Java 1.8 null annotations cause 'Contradictory null annotations' error [message #1287536 is a reply to message #1287468] Mon, 07 April 2014 22:07 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Mh, looks like we're inferring null type annotations too aggressively for the instantiation for the type parameter T.
Could you please file a bug with this example?
thanks,
Stephan
Re: Java 1.8 null annotations cause 'Contradictory null annotations' error [message #1288011 is a reply to message #1287536] Tue, 08 April 2014 07:42 Go to previous message
Tom van den Bege is currently offline Tom van den BegeFriend
Messages: 9
Registered: July 2009
Junior Member
No problem, here it is.


Thanks,
Tom
Previous Topic: Available Software Sites is empty after upgrading to Kepler
Next Topic:Can't step while remote debugging in latest Kepler
Goto Forum:
  


Current Time: Thu Apr 25 21:53:15 GMT 2024

Powered by FUDForum. Page generated in 0.03334 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top