It bothers me. The following compiles under Eclipse.
package com.example.gotchas; public class GenericHelper1 { static <T> T fail() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } public boolean argh() { return fail(); } public static void main(String[] args) {
But if I try to do a clean build using ant or on the command line using javac , I get the following:
src\com\example\gotchas\GenericHelper1.java:14: type parameters of <T>T cannot be determined; no unique maximal instance exists for type variable T with upper bounds boolean,java.lang.Object public boolean argh() { return fail(); } ^ 1 error
what gives, and how to fix it?
source share