Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 437050 - [1.8][null] incorrect "Nullness annotations are not applicable at this location", type variable used in throws
Summary: [1.8][null] incorrect "Nullness annotations are not applicable at this locati...
Status: VERIFIED DUPLICATE of bug 435570
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 8
: P3 normal (vote)
Target Milestone: 4.5 M1   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-10 09:16 EDT by Kivanc Muslu CLA
Modified: 2014-09-17 02:41 EDT (History)
5 users (show)

See Also:


Attachments
Minimal working code example to demonstrate the bug. (3.51 KB, application/x-zip-compressed)
2014-06-10 09:16 EDT, Kivanc Muslu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kivanc Muslu CLA 2014-06-10 09:16:32 EDT
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,
Comment 1 Kivanc Muslu CLA 2014-06-10 09:17:53 EDT
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,
Comment 2 Stephan Herrmann CLA 2014-06-10 09:26:56 EDT
Thanks for the report.

I'll take a look for 4.4.1
Comment 3 Kivanc Muslu CLA 2014-06-10 09:35:06 EDT
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 :)
Comment 4 Stephan Herrmann CLA 2014-07-16 13:45:14 EDT
I have a fix under test in the other bug.

*** This bug has been marked as a duplicate of bug 435570 ***
Comment 5 Stephan Herrmann CLA 2014-08-07 09:43:40 EDT
Adjusting milestone to the bug containing the fix.
Comment 6 shankha banerjee CLA 2014-09-17 02:28:02 EDT
Verified for Mars 4.5M2 using I20140915-2000 build.