我有以下使用 FEST 获取 JListFixture 的非通用方法:
public static JListFixture getJListFixtureNonGeneric(final FrameFixture frame) {
return frame.list(new GenericTypeMatcher<MyClass>(MyClass.class) {
@Override
protected boolean isMatching(MyClass component) {
return true;
}
});
}
我有以下使用 FEST 获取 JListFixture 的通用方法:
public static <T extends Component> JListFixture getJListFixture(final FrameFixture frame, final Class<T> t) {
return frame.list(new GenericTypeMatcher<T>(t) {
@Override
protected boolean isMatching(T component) {
return true;
}
});
}
在 Netbeans 7.3 中,非泛型方法编译时不会出错。然而,通用方法没有。编辑器窗口不显示任何编译错误(任何行号都没有红线)。但是,如果我尝试通过右键单击项目并单击“测试”来编译它,我会收到以下错误:
编译器 (1.7.0_21) 发生异常。在检查 Bug Parade 是否有重复项后,请在 Java 开发人员连接 ( http://java.sun.com/webapps/bugreport ) 提交一个错误。在报告中包含您的程序和以下诊断。谢谢你。
java.lang.AssertionError: Missing type variable in where clause T at com.sun.tools.javac.util.RichDiagnosticFormatter.unique(RichDiagnosticFormatter.java:234) at com.sun.tools.javac.util.RichDiagnosticFormatter.access$100(RichDiagnosticFormatter.java:67) at com.sun.tools.javac.util.RichDiagnosticFormatter$RichPrinter.visitTypeVar(RichDiagnosticFormatter.java:384) at com.sun.tools.javac.util.RichDiagnosticFormatter$RichPrinter.visitTypeVar(RichDiagnosticFormatter.java:326) ... C:\myProject\nbproject\build-impl.xml:1248: The following error occurred while executing this line: C:\myProject\nbproject\build-impl.xml:268: Compile failed; see the compiler error output for details.
stacktrace 中的第 1248 行对应于下面的 j2seproject3 元素:
<target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
<j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.test.dir}"/>
<copy todir="${build.test.classes.dir}">
<fileset dir="${test.test.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
</copy>
</target>
堆栈跟踪中的第 268 行指向以下内容:
<javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
...
有没有人遇到过这种情况或知道如何使它工作?这实际上是一个真正的错误吗?