这让我感到困惑。在Eclipse下,以下内容可以编译通过。
package com.example.gotchas;
public class GenericHelper1 {
static <T> T fail() throws UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
/**
* just calls fail()
* @return something maybe
*/
public boolean argh() { return fail(); }
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
但是,如果我试图使用 ant
进行干净构建,或者在命令行上使用 javac
,我会得到以下结果:
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
什么出了问题,我该怎么修复它?