-
Bug
-
Resolution: Fixed
-
P2
-
6
Following code sample causes compiler to throw error
(tools.jar should be on the classpath):
- Test.java --------------------------------------------
import static com.sun.tools.javac.tree.JCTree.Kind;
public class Test {
public static void main(String[] args) {
Kind assign = Kind.ASSIGN;
}
}
--------------------------------------------------------
Output is:
An exception has occurred in the compiler (1.6.0-beta2). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError
at com.sun.tools.javac.code.Symbol.clone(Symbol.java:120)
at com.sun.tools.javac.comp.Resolve.findVar(Resolve.java:488)
at com.sun.tools.javac.comp.Resolve.findIdent(Resolve.java:985)
at com.sun.tools.javac.comp.Resolve.resolveIdent(Resolve.java:1167)
at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:1634)
at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1547)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:288)
at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1719)
at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1522)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:288)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:303)
at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:606)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:691)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:288)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:323)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:339)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:638)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:288)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:323)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:557)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:288)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:323)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2590)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2521)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2457)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:891)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:867)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:660)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:633)
at com.sun.tools.javac.main.Main.compile(Main.java:761)
at com.sun.tools.javac.main.Main.compile(Main.java:686)
at com.sun.tools.javac.main.Main.compile(Main.java:675)
at com.sun.tools.javac.Main.compile(Main.java:70)
at com.sun.tools.javac.Main.main(Main.java:55)
If static import is not used, everything works fine:
--------------------------------------------------------
public class Test {
public static void main(String[] args) {
com.sun.tools.javac.tree.JCTree.Kind assign =
com.sun.tools.javac.tree.JCTree.Kind.ASSIGN;
}
}
--------------------------------------------------------
(tools.jar should be on the classpath):
- Test.java --------------------------------------------
import static com.sun.tools.javac.tree.JCTree.Kind;
public class Test {
public static void main(String[] args) {
Kind assign = Kind.ASSIGN;
}
}
--------------------------------------------------------
Output is:
An exception has occurred in the compiler (1.6.0-beta2). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError
at com.sun.tools.javac.code.Symbol.clone(Symbol.java:120)
at com.sun.tools.javac.comp.Resolve.findVar(Resolve.java:488)
at com.sun.tools.javac.comp.Resolve.findIdent(Resolve.java:985)
at com.sun.tools.javac.comp.Resolve.resolveIdent(Resolve.java:1167)
at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:1634)
at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1547)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:288)
at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1719)
at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1522)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:288)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:303)
at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:606)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:691)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:288)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:323)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:339)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:638)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:288)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:323)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:557)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:288)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:323)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2590)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2521)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2457)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:891)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:867)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:660)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:633)
at com.sun.tools.javac.main.Main.compile(Main.java:761)
at com.sun.tools.javac.main.Main.compile(Main.java:686)
at com.sun.tools.javac.main.Main.compile(Main.java:675)
at com.sun.tools.javac.Main.compile(Main.java:70)
at com.sun.tools.javac.Main.main(Main.java:55)
If static import is not used, everything works fine:
--------------------------------------------------------
public class Test {
public static void main(String[] args) {
com.sun.tools.javac.tree.JCTree.Kind assign =
com.sun.tools.javac.tree.JCTree.Kind.ASSIGN;
}
}
--------------------------------------------------------
- duplicates
-
JDK-6414483 REGRESSION/CONFORMANCE: compiler crash: lang/PKGS/pkgs057/pkgs05707 and lang/PKGS/pkgs057/pkgs05708
- Closed
- relates to
-
JDK-6225935 "import static" accessibility rules for symbols different for no reason
- Closed