| Summary: | [1.8][null] JDT null analysis "Null type safety" warning methos which accept a generic Enum | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Matthew DOnofrio <artist> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | Stephan Herrmann <stephan.herrmann> |
| Severity: | normal | ||
| Priority: | P3 | CC: | register.eclipse, stephan.herrmann |
| Version: | 4.8 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows NT | ||
| Whiteboard: | stalebug | ||
This is causing a LOT of warnings for me. Is there a way that I can disable this one warning across an entire project for now until this is fixed? change the parameter of stringFromEnum:
public static <E extends Enum<E>> String stringFromEnum(E key)
{
return "";
}
Could be as easy as implicitly marking the type argument in "extends Enum<SomeEnum>" as @NonNull, viz in ClassScope.connectEnumSuperclass()? Plus similar treatment when reading a binary enum. We should double check whether all references to that type parameter meet the criteria for nonnull. - Explicit use happens only in Enum.compareTo(E) and Enum.getDeclaringClass() - implicit methods valueOf() and values() already have special treatment. It looks so simple, feels like I'm missing s.t. :) Any other usage of Enum's type parameter? 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. |
I can't suppress this without explicitly adding a "@SuppressWarnings("null")" no matter how I try to annotate this. --- package com.codespunk; import org.eclipse.jdt.annotation.NonNullByDefault; @NonNullByDefault public class Test { public enum SomeEnum { A } public static <E extends Enum<E>> String stringFromEnum( Enum<E> key) { return ""; } @SuppressWarnings("unused") public static void main( String[] args) { // Null type safety (type annotations): The expression of type // 'Test.SomeEnum' needs unchecked conversion to conform to // '@NonNull Enum<Test.@NonNull SomeEnum>', corresponding supertype is // 'Enum<Test.SomeEnum>' String a = stringFromEnum(SomeEnum.A); } }