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

crash: java.lang.AssertionError at com.sun.tools.javac.comp.Lower.abstractLval(Lower.java:1853)

XMLWordPrintable

    • b71
    • x86, sparc
    • linux, solaris_10, windows_2000, windows_xp
    • Verified

      FULL PRODUCT VERSION :
      java version "1.5.0_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      When compiling the following code, javac generates an AssertionError:

      class Reference<T> {
      T value;

      Reference(T value) {
      this.value = value;
      }
      }

      public class GenericInABox {

      public static void main(String[] args) {
      Reference<Integer> reference = new Reference<Integer>(0);
      reference.value++;
      System.out.println(reference.value);
      }
      }


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1- Create a file names GenericInABox.java
      2- Put the code below in the file and save.
      /* ======================== */
      class Reference<T> {
      T value;

      Reference(T value) {
      this.value = value;
      }
      }

      public class GenericInABox {

      public static void main(String[] args) {
      Reference<Integer> reference = new Reference<Integer>(0);
      reference.value++;
      System.out.println(reference.value);
      }
      }
      /* ======================== */
      3- on the command prompt execute the following line:
      javac GenericInABox.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Something like:

      GenericInABox.java:18: operator + cannot be applied to java.lang.Object,int
                reference.value += 1;
                                 ^
      ACTUAL -
      An exception has occurred in the compiler (1.5.0_05). 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: (Integer)reference.value
      at com.sun.tools.javac.comp.Lower.abstractLval(Lower.java:1853)
      at com.sun.tools.javac.comp.Lower.lowerBoxedPostop(Lower.java:2659)
      at com.sun.tools.javac.comp.Lower.visitUnary(Lower.java:2696)
      at com.sun.tools.javac.tree.Tree$Unary.accept(Tree.java:910)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
      at com.sun.tools.javac.tree.TreeTranslator.visitExec(TreeTranslator.java:227)
      at com.sun.tools.javac.tree.Tree$Exec.accept(Tree.java:728)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
      at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:54)
      at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:145)
      at com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:2927)
      at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:535)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
      at com.sun.tools.javac.tree.TreeTranslator.visitMethodDef(TreeTranslator.java:129)
      at com.sun.tools.javac.comp.Lower.visitMethodDefInternal(Lower.java:2267)
      at com.sun.tools.javac.comp.Lower.visitMethodDef(Lower.java:2186)
      at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:478)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
      at com.sun.tools.javac.comp.Lower.visitClassDef(Lower.java:1989)
      at com.sun.tools.javac.tree.Tree$ClassDef.accept(Tree.java:434)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1901)
      at com.sun.tools.javac.comp.Lower.translateTopLevelClass(Lower.java:3064)
      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:496)
      at com.sun.tools.javac.main.Main.compile(Main.java:592)
      at com.sun.tools.javac.main.Main.compile(Main.java:544)
      at com.sun.tools.javac.Main.compile(Main.java:67)
      at com.sun.tools.javac.Main.main(Main.java:52)


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An exception has occurred in the compiler (1.5.0_05). 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: (Integer)reference.value
      at com.sun.tools.javac.comp.Lower.abstractLval(Lower.java:1853)
      at com.sun.tools.javac.comp.Lower.lowerBoxedPostop(Lower.java:2659)
      at com.sun.tools.javac.comp.Lower.visitUnary(Lower.java:2696)
      at com.sun.tools.javac.tree.Tree$Unary.accept(Tree.java:910)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
      at com.sun.tools.javac.tree.TreeTranslator.visitExec(TreeTranslator.java:227)
      at com.sun.tools.javac.tree.Tree$Exec.accept(Tree.java:728)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
      at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:54)
      at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:145)
      at com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:2927)
      at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:535)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
      at com.sun.tools.javac.tree.TreeTranslator.visitMethodDef(TreeTranslator.java:129)
      at com.sun.tools.javac.comp.Lower.visitMethodDefInternal(Lower.java:2267)
      at com.sun.tools.javac.comp.Lower.visitMethodDef(Lower.java:2186)
      at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:478)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
      at com.sun.tools.javac.comp.Lower.visitClassDef(Lower.java:1989)
      at com.sun.tools.javac.tree.Tree$ClassDef.accept(Tree.java:434)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
      at com.sun.tools.javac.comp.Lower.translate(Lower.java:1901)
      at com.sun.tools.javac.comp.Lower.translateTopLevelClass(Lower.java:3064)
      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:496)
      at com.sun.tools.javac.main.Main.compile(Main.java:592)
      at com.sun.tools.javac.main.Main.compile(Main.java:544)
      at com.sun.tools.javac.Main.compile(Main.java:67)
      at com.sun.tools.javac.Main.main(Main.java:52)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Reference<T> {
      T value;

      Reference(T value) {
      this.value = value;
      }
      }

      public class GenericInABox {

      public static void main(String[] args) {
      Reference<Integer> reference = new Reference<Integer>(0);
      reference.value++;
      System.out.println(reference.value);
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Change the code to (to be able to get a regular compiler error)

      class Reference<T> {
      T value;

      Reference(T value) {
      this.value = value;
      }
      }

      public class GenericInABox {

      public static void main(String[] args) {
      Reference<Integer> reference = new Reference<Integer>(0);
      reference.value += 1;
      System.out.println(reference.value);
      }
      }

      or (to be able to run)

      class Reference<T> {
      T value;

      Reference(T value) {
      this.value = value;
      }
      }

      public class GenericInABox {

      public static void main(String[] args) {
      Reference<Integer> reference = new Reference<Integer>(0);
      reference.value = reference.value + 1;
      System.out.println(reference.value);
      }
      }

            ahe Peter Ahe
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: