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

Compiler throws an ArrayIndexOutOfBoundsException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 5.0
    • tools
    • x86
    • windows_xp



      Name: gm110360 Date: 02/11/2004


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

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP PRo Build 2600.xpsp2.030422-1633(Sevice Pack 1)

      A DESCRIPTION OF THE PROBLEM :
      The compiler threw an exception when compiling a trial program.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the code in the example.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The code would compile or maybe not!
      ACTUAL -
      Error message as below

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Command : "D:\j2sdk1.5.0\bin\javac.exe" -deprecation -source 1.5 "E:\Beg Java 1.5\Examples\Test\TryItOut.java" -Xlint:unchecked
      Directory : "E:\Beg Java 1.5\Examples\Test"
      An exception has occurred in the compiler (1.5.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.ArrayIndexOutOfBoundsException: -1
      at com.sun.tools.javac.jvm.Code$State.pop(Code.java:1509)
      at com.sun.tools.javac.jvm.Code.emitop0(Code.java:587)
      at com.sun.tools.javac.jvm.Items$Item.coerce(Items.java:236)
      at com.sun.tools.javac.jvm.Items$Item.coerce(Items.java:249)
      at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:806)
      at com.sun.tools.javac.jvm.Gen.completeBinop(Gen.java:1996)
      at com.sun.tools.javac.jvm.Gen.visitAssignop(Gen.java:1795)
      at com.sun.tools.javac.tree.Tree$Assignop.accept(Tree.java:899)
      at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:804)
      at com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1599)
      at com.sun.tools.javac.tree.Tree$Exec.accept(Tree.java:734)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:651)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:672)
      at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:723)
      at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:970)
      at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:540)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:651)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:672)
      at com.sun.tools.javac.jvm.Gen.visitIf(Gen.java:1583)
      at com.sun.tools.javac.tree.Tree$If.accept(Tree.java:721)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:651)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:672)
      at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:723)
      at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:970)
      at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:540)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:651)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:672)
      at com.sun.tools.javac.jvm.Gen.genLoop(Gen.java:1016)
      at com.sun.tools.javac.jvm.Gen.visitForLoop(Gen.java:987)
      at com.sun.tools.javac.tree.Tree$ForLoop.accept(Tree.java:586)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:651)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:672)
      at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:723)
      at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:970)
      at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:540)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:651)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
      at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:908)
      at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:844)
      at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:482)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:651)
      at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2177)
      at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:325)
      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:467)
      at com.sun.tools.javac.main.Main.compile(Main.java:593)
      at com.sun.tools.javac.main.Main.compile(Main.java:545)
      at com.sun.tools.javac.Main.compile(Main.java:44)
      at com.sun.tools.javac.Main.main(Main.java:35)



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class TryItOut {
        public static void main(String[] args) {
          double ave = average(2,3, 4.5, 6, 7.8, 99, 56.3);
          System.out.println("Average is "+ave);
        }

        static double average(Object ... args) {
          double sum = 0.0;
          for(int i = 0 ; i<args.length ; i++) {
            if(args[i] instanceof Double) {
              sum += (Double)args[i];
            }
            if(args[i] instanceof Integer) {
              sum += (Integer)args[i];
            }
            if(args[i] instanceof Float) {
              sum += (Float)args[i];
            }
          }
          return sum/args.length;
        }
      }

      ---------- END SOURCE ----------
      (Incident Review ID: 238376)
      ======================================================================

            gafter Neal Gafter (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: