Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to make a generic null annotated method
How to make a generic null annotated method [message #1748668] Sat, 26 November 2016 12:11 Go to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 125
Registered: July 2009
Senior Member
I have this:
static <A extends Annotation> @Nullable A getSomething( Class<A> annotationClass)


When i call it like this:
getSomething(MyAnnotation.class);


I get this error:
Null type safety (type annotations): The expression of type 'Class<MyAnnotation>' needs unchecked conversion to conform to 'Class<@NonNull MyAnnotation>'

I played with different variants, but I couldn't get it free of warning.



Re: How to make a generic null annotated method [message #1748669 is a reply to message #1748668] Sat, 26 November 2016 12:49 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1504
Registered: July 2009
Senior Member
I assume you have @NonNullByDefault applying to the code in question? Otherwise I wouldn't see any issue at all.

In that case you would be seeing https://bugs.eclipse.org/477719 which was fixed as of 4.6M4. Which version are you using, could you please try a recent version?
Re: How to make a generic null annotated method [message #1748670 is a reply to message #1748669] Sat, 26 November 2016 13:47 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 125
Registered: July 2009
Senior Member
Yes, indeed. This is specified.
Re: How to make a generic null annotated method [message #1748671 is a reply to message #1748670] Sat, 26 November 2016 13:48 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 125
Registered: July 2009
Senior Member
I am running Version: Neon.1a Release (4.6.1)
Re: How to make a generic null annotated method [message #1748672 is a reply to message #1748671] Sat, 26 November 2016 14:13 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1504
Registered: July 2009
Senior Member
Frank Benoit wrote on Sat, 26 November 2016 14:48
I am running Version: Neon.1a Release (4.6.1)


If indeed you see the "unchecked conversion" warning still in Neon, then a bug report with a full example would be appreciated, since from what you showed so far, I cannot reproduce the problem in Neon (but could in older versions).
Re: How to make a generic null annotated method [message #1748673 is a reply to message #1748672] Sat, 26 November 2016 14:39 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 125
Registered: July 2009
Senior Member
Hm, while trying to create this, i cannot reproduce too.
In my original code, i use aspectj nature.
http://download.eclipse.org/tools/ajdt/46/dev/update

When i add the aspectj nature to my sample project, the warning shows up.


Re: How to make a generic null annotated method [message #1748675 is a reply to message #1748673] Sat, 26 November 2016 14:44 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 125
Registered: July 2009
Senior Member
I created a bug for AJDT
https://bugs.eclipse.org/bugs/show_bug.cgi?id=508230
Re: How to make a generic null annotated method [message #1748710 is a reply to message #1748675] Sun, 27 November 2016 13:13 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1504
Registered: July 2009
Senior Member
Great you found this.

The readme of the latest AspectJ release has this:
Quote:
The JDT compiler inside AspectJ has been upgraded to the Eclipse Mars.2 level (commit #a7bba8b1).


So for now, in any AspectJ projects you'll be missing all JDT compiler bug fixes from the Neon cycle.
Re: How to make a generic null annotated method [message #1748711 is a reply to message #1748710] Sun, 27 November 2016 13:50 Go to previous message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 125
Registered: July 2009
Senior Member
OMG, this is a setback for me.
I spend so many hours on this code changes.
Thanks for this info.

Another bug I created:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=508247

Previous Topic:what is org.eclipse.jdt.core.compiler.codegen.methodParameters?
Next Topic:SWT Shell init Fails
Goto Forum:
  


Current Time: Tue Sep 26 20:13:26 GMT 2017

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

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