Zero annotation processor in Eclipse

I am using the Eclipse JDT Null annotation processor and I am getting some weird behavior when using java.lang.Class.

package test;

import org.eclipse.jdt.annotation.Nullable;

public class AnnotationSpul {

    @Nullable
    public <V> V get1(Class<V> type) {
        return get2(type); //This line has a warning
    }

    @Nullable
    public <V> V get2(Class<V> type) {
        return null;
    }
}

      

This is my package information:

@NonNullByDefault({ PARAMETER, RETURN_TYPE, FIELD })
package test;

import static org.eclipse.jdt.annotation.DefaultLocation.FIELD;
import static org.eclipse.jdt.annotation.DefaultLocation.PARAMETER;
import static org.eclipse.jdt.annotation.DefaultLocation.RETURN_TYPE;

import org.eclipse.jdt.annotation.NonNullByDefault;

      

The warning I'm getting is: "An expression like '@NonNull Class' requires a raw conversion to match' @NonNull Class <@Nullable V>"

I don't understand why I am getting the warning. The method signatures are the same, so why does the passed value need to be converted? Why is it type

derived as @NonNull Class<V>

one method and @NonNull Class<@Nullable V>

another?

+3


source to share


1 answer


This was a bug in ecj 4.4 . Combined with type inference and null inference, ecj over-inferred the type parameter @Nullable V

.



The bug was fixed in 4.5M5 , so the upcoming 4.5 (Mars) release will take the program as expected.

+2


source







All Articles