Duplicate :
|
FULL PRODUCT VERSION : 1.7.0_01 FULL OS VERSION : Windows Vista 32 bit A DESCRIPTION OF THE PROBLEM : While building a JavaFX 2.0 application i wanted to use the new string in switches feature on the "KeyEvent" class of JavaFX. I wanted to switch on the different types of KeyEvents, i.e. "KEY_PRESSED" or "KEY_RELEASED". THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try ERROR MESSAGES/STACK TRACES THAT OCCUR : An exception has occurred in the compiler (1.7.0_01). 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.NullPointerException at com.sun.tools.javac.comp.Lower.visitStringSwitch(Lower.java:3456) at com.sun.tools.javac.comp.Lower.visitSwitch(Lower.java:3357) at com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:959) at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58) at com.sun.tools.javac.comp.Lower.translate(Lower.java:2160) at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70) at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:160) at com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:3311) at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:781) at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58) at com.sun.tools.javac.comp.Lower.translate(Lower.java:2160) at com.sun.tools.javac.tree.TreeTranslator.visitMethodDef(TreeTranslator.java:144) at com.sun.tools.javac.comp.Lower.visitMethodDefInternal(Lower.java:2619) at com.sun.tools.javac.comp.Lower.visitMethodDef(Lower.java:2538) at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:669) at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58) at com.sun.tools.javac.comp.Lower.translate(Lower.java:2160) at com.sun.tools.javac.comp.Lower.visitClassDef(Lower.java:2283) at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:591) at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58) at com.sun.tools.javac.comp.Lower.translate(Lower.java:2160) at com.sun.tools.javac.comp.Lower.translate(Lower.java:2180) at com.sun.tools.javac.comp.Lower.translateTopLevelClass(Lower.java:3650) at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1393) at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1271) at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:870) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:829) at com.sun.tools.javac.main.Main.compile(Main.java:417) at com.sun.tools.javac.main.Main.compile(Main.java:331) at com.sun.tools.javac.main.Main.compile(Main.java:322) at com.sun.tools.javac.Main.compile(Main.java:76) at com.sun.tools.javac.Main.main(Main.java:61) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- @Override public void handle(KeyEvent evt) { switch(evt.getEventType().getName()) { case("KEY_PRESSED"): System.out.println("key pressed"); break; case("KEY_RELEASED"): System.out.println("key released"); break; default: } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Workaround would be to use consecutive if/else if conditions, but i couldn��t manage to run this with strings in switch