Community
Participate
Working Groups
Created attachment 244113 [details] Minimal working code example to demonstrate the bug. Hi, When using Java8 nullness type qualifiers (through org.eclipse.jdt.annotation package v2.0.0) Eclipse compiler generates an incorrect error for the following case: - The package has the default nullness annotation: [code] @org.eclipse.jdt.annotation.NonNullByDefault [/code] - and a class defines a Generic type that extends an Exception and attempts to declare a method that throws this Generic exception. Attached is an Eclipse plug-in project with a minimal working code example. When compiled with Java 1.8 compiler using null analysis, the example gives the following error: "Nullness annotations are not applicable at this location" for the Generic exception that the method attempts to throw. I have first created a question in the Eclipse JDT forums: https://www.eclipse.org/forums/index.php/m/1385677/#msg_1385677 where Stephan Herrmann identified this behavior as a bug and suggested me to create a bug report. Please let me know if I can provide additional information. Thanks and best regards,
I just realized that I forgot to mention: I am not sure about the "component" part of this bug. It is related to how annotations are used in the nullness analysis. I have selected APT, but feel free to change it. Thanks,
Thanks for the report. I'll take a look for 4.4.1
My pleasure, thanks for looking into it. Also, per our discussion on the board, the following indeed works, too: package nullness; import org.eclipse.jdt.annotation.NonNullByDefault; import static org.eclipse.jdt.annotation.DefaultLocation.PARAMETER; import static org.eclipse.jdt.annotation.DefaultLocation.RETURN_TYPE; import static org.eclipse.jdt.annotation.DefaultLocation.FIELD; import static org.eclipse.jdt.annotation.DefaultLocation.TYPE_ARGUMENT; @NonNullByDefault({PARAMETER, RETURN_TYPE, FIELD, TYPE_ARGUMENT}) public abstract class Generics<Ex extends Throwable> { protected abstract void compute() throws Ex; } might provide additional information while debugging :)
I have a fix under test in the other bug. *** This bug has been marked as a duplicate of bug 435570 ***
Adjusting milestone to the bug containing the fix.
Verified for Mars 4.5M2 using I20140915-2000 build.