Bug 480717 - Incorrect @Nonnull processing for static String
Summary: Incorrect @Nonnull processing for static String
Status: CLOSED DUPLICATE of bug 331649
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5.1   Edit
Hardware: PC Windows NT
: P3 normal with 1 vote (vote)
Target Milestone: 4.3 M5   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-27 02:06 EDT by Stanislav Spiridonov CLA
Modified: 2020-03-16 19:40 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Spiridonov CLA 2015-10-27 02:06:47 EDT
Simple case:

3 classes: Base with Nonnull constructor, Complex extends Base and IdHolder that contains Nonnull static String.

package org.jresearch;

import javax.annotation.Nonnull;

public class IdHolder {

	@Nonnull
	public static final String ID = "id"; //$NON-NLS-1$

}



package org.jresearch;

import javax.annotation.Nonnull;

public class Base {

	@Nonnull
	private final String id;

	public Base(@Nonnull final String id) {
		this.id = id;
	}

	@Nonnull
	public String getId() {
		return id;
	}

}


package org.jresearch;

public class Complex extends Base {

	// @SuppressWarnings("all")
	// @SuppressWarnings("null")
	public Complex() {
		super(IdHolder.ID);
	}

}

In class Complex on the line super(IdHolder.ID); I have warning "Null type safety: The expression of type 'String' needs unchecked conversion to conform to '@Nonnull String'"

If I uncomment line with @SuppressWarnings("null") the warning disappeared, but I have the new one "Unnecessary @SuppressWarnings("null")"

And even @SuppressWarnings("all") complete removes all warnings
Comment 1 Eclipse Genie CLA 2020-03-16 10:33:06 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 2 Stephan Herrmann CLA 2020-03-16 19:40:29 EDT
I can reproduce in 4.2.x but this works since 4.3M5, likely due to fix for bug 331649 (2013).

I specifically tested the mentioned version 4.5.1 (OK).

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