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

InternalError when assert statement compile with void as Expr2

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_8

      Description



      Name: viR10068 Date: 06/04/2001


      The "A Simple Assertion Facility For the Java Programming Language
      (Proposed Final Draft)" says:
      In both forms of the assert statement, Expression1 must have type boolean
      or a compile-time error results. In the second form, Expression2
      must have a value or a compile-time error results. In other words,
      Expression2 must not be void.

      However, the compiler crashes with InternalError instead of reporting a
      compile-time error if the void is used.

      To reproduce this bug:
      1. compile the source A.java with flag -source 1.4

      ---------------------------- A.java -----------------------------------
      package test;

      import java.io.PrintStream;

      class A {
          void getVal() {}
          public int run() {
              assert false: getVal();
              return 0;
          }
      }
      ------------------------------------------------------------------------

      The run log:
      % java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
      % javac -source 1.4 -d . A.java
      An exception has occurred in the compiler (1.4.0-beta). Please file a bug at the Java
      Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi) after checking the Bug
      Parade for duplicates. Include your program and the following diagnostic in your report.
      Thank you.
      java.lang.InternalError
              at com.sun.tools.javac.v8.comp.Items$Item.load(Items.java:187)
              at com.sun.tools.javac.v8.comp.Items$Item.coerce(Items.java:240)
              at com.sun.tools.javac.v8.comp.Items$Item.coerce(Items.java:260)
              at com.sun.tools.javac.v8.comp.Gen.genExpr(Gen.java:553)
              at com.sun.tools.javac.v8.comp.Gen._case(Gen.java:1456)
              at com.sun.tools.javac.v8.tree.Tree$TypeCast.visit(Tree.java:995)
              at com.sun.tools.javac.v8.comp.Gen.genExpr(Gen.java:551)
              at com.sun.tools.javac.v8.comp.Gen.genArgs(Gen.java:572)
              at com.sun.tools.javac.v8.comp.Gen._case(Gen.java:1134)
              at com.sun.tools.javac.v8.tree.Tree$NewClass.visit(Tree.java:885)
              at com.sun.tools.javac.v8.comp.Gen.genExpr(Gen.java:551)
              at com.sun.tools.javac.v8.comp.Gen._case(Gen.java:1103)
              at com.sun.tools.javac.v8.tree.Tree$Throw.visit(Tree.java:824)
              at com.sun.tools.javac.v8.comp.Gen.genDef(Gen.java:411)
              at com.sun.tools.javac.v8.comp.Gen.genStat(Gen.java:449)
              at com.sun.tools.javac.v8.comp.Gen.genStat(Gen.java:435)
              at com.sun.tools.javac.v8.comp.Gen._case(Gen.java:1037)
              at com.sun.tools.javac.v8.tree.Tree$If.visit(Tree.java:739)
              at com.sun.tools.javac.v8.comp.Gen.genDef(Gen.java:411)
              at com.sun.tools.javac.v8.comp.Gen.genStat(Gen.java:449)
              at com.sun.tools.javac.v8.comp.Gen.genStat(Gen.java:435)
              at com.sun.tools.javac.v8.comp.Gen.genStats(Gen.java:482)
              at com.sun.tools.javac.v8.comp.Gen._case(Gen.java:653)
              at com.sun.tools.javac.v8.tree.Tree$Block.visit(Tree.java:530)
              at com.sun.tools.javac.v8.comp.Gen.genDef(Gen.java:411)
              at com.sun.tools.javac.v8.comp.Gen.genStat(Gen.java:449)
              at com.sun.tools.javac.v8.comp.Gen.genStat(Gen.java:435)
              at com.sun.tools.javac.v8.comp.Gen.genMethod(Gen.java:610)
              at com.sun.tools.javac.v8.comp.Gen._case(Gen.java:584)
              at com.sun.tools.javac.v8.tree.Tree$MethodDef.visit(Tree.java:465)
              at com.sun.tools.javac.v8.comp.Gen.genDef(Gen.java:411)
              at com.sun.tools.javac.v8.comp.Gen.genClass(Gen.java:1579)
              at com.sun.tools.javac.v8.JavaCompiler.genCode(JavaCompiler.java:324)
              at com.sun.tools.javac.v8.JavaCompiler.compile(JavaCompiler.java:431)
              at com.sun.tools.javac.v8.Main.compile(Main.java:469)
              at com.sun.tools.javac.Main.compile(Main.java:23)
              at com.sun.tools.javac.Main.main(Main.java:14)
      %

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              vivsunw Viv Viv (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: