Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8139244

compiler crashes with exception on unary operation over boxed type of primitive type

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P1 P1
    • None
    • 9.1
    • tools
    • None

      Code:

      $ cat UnaryOnBoxed.java
      public class UnaryOnBoxed {
          public static void main(String args[]) {
              Float d = new Float(3);
              Object o = ~d;
          }
      }

      Java version:

       Java version:

      $ javac -version
      javac 1.9.0-ea

      Actual compilation result:

      $ javac UnaryOnBoxed.java
      An exception has occurred in the compiler (1.9.0-ea). Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) after checking the database for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.ClassCastException: com.sun.tools.javac.code.Symtab$4 cannot be cast to com.sun.tools.javac.code.Symbol$OperatorSymbol
      at com.sun.tools.javac.jvm.Gen.visitUnary(Gen.java:1947)
      at com.sun.tools.javac.tree.JCTree$JCUnary.accept(JCTree.java:1904)
      at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:827)
      at com.sun.tools.javac.jvm.Gen.visitVarDef(Gen.java:1024)
      at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:920)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:617)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:652)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:638)
      at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:689)
      at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1037)
      at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:984)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:617)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:652)
      at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:911)
      at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:874)
      at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:836)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:617)
      at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2355)
      at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:715)
      at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1541)
      at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1505)
      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:871)
      at com.sun.tools.javac.main.Main.compile(Main.java:254)
      at com.sun.tools.javac.main.Main.compile(Main.java:142)
      at com.sun.tools.javac.Main.compile(Main.java:56)
      at com.sun.tools.javac.Main.main(Main.java:42)

      Expected result:

      Have compiler.err.operator.cant.be.applied error.

      For example, on Boolean type like
              Boolean b = new Boolean("true");
              Object o = ~b;

      compiler says:

      compiler.err.operator.cant.be.applied: ~, java.lang.Boolean
      1 error

            Unassigned Unassigned
            spikalev Sergei Pikalev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: