Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 484734

Summary: [compiler][null] nullability annotation with arrays results in unavoidable warning.
Product: [Eclipse Project] JDT Reporter: Sergey Olefir <solf.gm>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: stephan.herrmann
Version: 4.5.1   
Target Milestone: 4.6 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Eclipse project demonstrating the problem none

Description Sergey Olefir CLA 2015-12-20 12:30:32 EST
Created attachment 258815 [details]
Eclipse project demonstrating the problem

In a fairly straightforward case of trying to declare array without null elements compiler appears to get confused -- you get the choice of either 'redundant nullness annotation' or 'unchecked conversion to @Nonnull' -- appears impossible to actually fix it so there's no warning.

Steps:
Eclipse eclipse-jee-mars-1-win32-x86_64.zip

Help->About:
Version: Mars.1 Release (4.5.1)
Build id: 20150924-1200

JDT core
org.eclipse.jdt.core_3.11.1.v20150902-1521.jar

java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)


Project is attached with all relevant settings set at project level.

Use "Import existing project into workspace" functionality.

See ArrayNullabilityBug.java (in case no warnings are reported, make trivial change (e.g. add space) and re-save).
Comment 1 Stephan Herrmann CLA 2015-12-20 13:03:07 EST
Thanks, I can reproduce in 4.5.1.

Starting with 4.6M3 the variant *with* @NonNull on the field declaration (affecting the array element type) is accepted with no error/warning.

*** This bug has been marked as a duplicate of bug 467094 ***