JavaFX编译器编译重载方法的一处BUG
直接看测试代码吧,一共2个类:BugTest.fx和A.fx,SDK版本是1.2.3。
/*
* BugTest.fx
*
* Created on 2010-2-25, 22:05:11
*/
package org.jqueen.fx.bug;
/**
* @author Leon
*/
public class BugTest {
// 取消该方法注释编译将抛出异常
// function test(a: A): Void {
// test(5);
// }
function test(s: String): Void {
test( 5 );
}
function test(i: Integer): Void {
}
}
* BugTest.fx
*
* Created on 2010-2-25, 22:05:11
*/
package org.jqueen.fx.bug;
/**
* @author Leon
*/
public class BugTest {
// 取消该方法注释编译将抛出异常
// function test(a: A): Void {
// test(5);
// }
function test(s: String): Void {
test( 5 );
}
function test(i: Integer): Void {
}
}
/*
* A.fx
*
* Created on 2010-2-25, 22:10:45
*/
package org.jqueen.fx.bug;
/**
* @author Leon
*/
public mixin class A { }
* A.fx
*
* Created on 2010-2-25, 22:10:45
*/
package org.jqueen.fx.bug;
/**
* @author Leon
*/
public mixin class A { }
BugTest里实现了3个带输入参数的重载方法,第一个方法的参数是自定义类型A,
A被声明为mixin,后2个的参数是原始类型。只有在第一个方法被注释的情况下该类才可以被编译通过,否则编译器会抛出异常:
An exception has occurred in the OpenJavafx compiler. Please file a bug at the Openjfx-compiler issues home (https://openjfx-compiler.dev.java.net/Issues) after checking for duplicates. Include the following diagnostic in your report and, if possible, the source code which triggered this problem. Thank you.
java.lang.ClassCastException: com.sun.tools.javac.code.Symbol$ClassSymbol
at com.sun.tools.javafx.code.JavafxTypes.asSuper(JavafxTypes.java:202)
at com.sun.tools.javac.code.Types.isSubtypeUnchecked(Types.java:305)
at com.sun.tools.javafx.comp.JavafxResolve.argumentsAcceptable(JavafxResolve.java:421)
at com.sun.tools.javafx.comp.JavafxResolve.rawInstantiate(JavafxResolve.java:387)
at com.sun.tools.javafx.comp.JavafxResolve.selectBest(JavafxResolve.java:711)
at com.sun.tools.javafx.comp.JavafxResolve.findMemberWithoutAccessChecks(JavafxResolve.java:952)
at com.sun.tools.javafx.comp.JavafxResolve.findMember(JavafxResolve.java:906)
at com.sun.tools.javafx.comp.JavafxResolve.findMember(JavafxResolve.java:886)
at com.sun.tools.javafx.comp.JavafxResolve.findVar(JavafxResolve.java:567)
at com.sun.tools.javafx.comp.JavafxResolve.findIdent(JavafxResolve.java:1228)
at com.sun.tools.javafx.comp.JavafxResolve.resolveIdent(JavafxResolve.java:1423)
at com.sun.tools.javafx.comp.JavafxAttr.visitIdent(JavafxAttr.java:506)
at com.sun.tools.javafx.tree.JFXIdent.accept(JFXIdent.java:52)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:280)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:265)
at com.sun.tools.javafx.comp.JavafxAttr.attribExpr(JavafxAttr.java:311)
at com.sun.tools.javafx.comp.JavafxAttr.visitFunctionInvocation(JavafxAttr.java:2239)
at com.sun.tools.javafx.tree.JFXFunctionInvocation.accept(JFXFunctionInvocation.java:53)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:280)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:265)
at com.sun.tools.javafx.comp.JavafxAttr.attribExpr(JavafxAttr.java:303)
at com.sun.tools.javafx.comp.JavafxAttr.visitBlockExpression(JavafxAttr.java:1373)
at com.sun.tools.javafx.tree.JFXBlock.accept(JFXBlock.java:83)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:280)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:265)
at com.sun.tools.javafx.comp.JavafxAttr.attribExpr(JavafxAttr.java:311)
at com.sun.tools.javafx.comp.JavafxAttr.finishFunctionDefinition(JavafxAttr.java:1863)
at com.sun.tools.javafx.comp.JavafxMemberEnter$SymbolCompleter.complete(JavafxMemberEnter.java:646)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:400)
at com.sun.tools.javafx.comp.JavafxAttr.visitFunctionDefinition(JavafxAttr.java:1658)
at com.sun.tools.javafx.tree.JFXFunctionDefinition.accept(JFXFunctionDefinition.java:93)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:280)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:265)
at com.sun.tools.javafx.comp.JavafxAttr.attribExpr(JavafxAttr.java:321)
at com.sun.tools.javafx.comp.JavafxMemberEnter$SymbolCompleter.complete(JavafxMemberEnter.java:643)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:400)
at com.sun.tools.javafx.comp.JavafxResolve.findMemberWithoutAccessChecks(JavafxResolve.java:943)
at com.sun.tools.javafx.comp.JavafxResolve.findMember(JavafxResolve.java:906)
at com.sun.tools.javafx.comp.JavafxResolve.findMember(JavafxResolve.java:886)
at com.sun.tools.javafx.comp.JavafxResolve.findVar(JavafxResolve.java:567)
at com.sun.tools.javafx.comp.JavafxResolve.findIdent(JavafxResolve.java:1228)
at com.sun.tools.javafx.comp.JavafxResolve.resolveIdent(JavafxResolve.java:1423)
at com.sun.tools.javafx.comp.JavafxAttr.visitIdent(JavafxAttr.java:506)
at com.sun.tools.javafx.tree.JFXIdent.accept(JFXIdent.java:52)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:280)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:265)
at com.sun.tools.javafx.comp.JavafxAttr.attribExpr(JavafxAttr.java:311)
at com.sun.tools.javafx.comp.JavafxAttr.visitFunctionInvocation(JavafxAttr.java:2239)
at com.sun.tools.javafx.tree.JFXFunctionInvocation.accept(JFXFunctionInvocation.java:53)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:280)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:265)
at com.sun.tools.javafx.comp.JavafxAttr.attribExpr(JavafxAttr.java:303)
at com.sun.tools.javafx.comp.JavafxAttr.visitBlockExpression(JavafxAttr.java:1373)
at com.sun.tools.javafx.tree.JFXBlock.accept(JFXBlock.java:83)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:280)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:265)
at com.sun.tools.javafx.comp.JavafxAttr.attribExpr(JavafxAttr.java:311)
at com.sun.tools.javafx.comp.JavafxAttr.finishFunctionDefinition(JavafxAttr.java:1863)
at com.sun.tools.javafx.comp.JavafxMemberEnter$SymbolCompleter.complete(JavafxMemberEnter.java:646)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:400)
at com.sun.tools.javafx.comp.JavafxAttr.visitFunctionDefinition(JavafxAttr.java:1658)
at com.sun.tools.javafx.tree.JFXFunctionDefinition.accept(JFXFunctionDefinition.java:93)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:280)
at com.sun.tools.javafx.comp.JavafxAttr.attribTree(JavafxAttr.java:265)
at com.sun.tools.javafx.comp.JavafxAttr.attribDecl(JavafxAttr.java:334)
at com.sun.tools.javafx.comp.JavafxAttr.attribClassBody(JavafxAttr.java:3696)
at com.sun.tools.javafx.comp.JavafxAttr.attribClass(JavafxAttr.java:2808)
at com.sun.tools.javafx.comp.JavafxAttr.attribClass(JavafxAttr.java:2763)
at com.sun.tools.javafx.main.JavafxCompiler.attribute(JavafxCompiler.java:936)
at com.sun.tools.javafx.main.JavafxCompiler.compile2(JavafxCompiler.java:782)
at com.sun.tools.javafx.main.JavafxCompiler.compile(JavafxCompiler.java:685)
at com.sun.tools.javafx.main.Main.compile(Main.java:624)
at com.sun.tools.javafx.main.Main.compile(Main.java:312)
at com.sun.tools.javafx.Main.compile(Main.java:84)
at com.sun.tools.javafx.Main.main(Main.java:69)