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

Server compiler leads to data corruption when expression throws an Exception

XMLWordPrintable

    • b02
    • generic
    • generic
    • Verified

        The following test case results in different results when running in -Xcomp and -Xint or -Xmixed modes.

        > java -server -Xint Tester
        Got java.lang.NegativeArraySizeException
        Tester.var_bad = 2 (expected 2)

        > java -server -Xmixed Tester
        Got java.lang.NegativeArraySizeException
        Tester.var_bad = 2 (expected 2)

        > java -server -Xcomp -XX:CompileOnly=Tester Tester
        Got java.lang.NegativeArraySizeException
        Tester.var_bad = 1 (expected 2)

        === Tester.java ===

        public class Tester {
           static int var_bad = 1;

           public static void main(String[] args)
           {
              var_bad++;

              try {
                 for (int i = 0; i < 10; i++) (new byte[((byte)-1 << i)])[0] = 0;
              }
              catch (Exception e) { System.out.println("Got " + e); }

              System.out.println("Tester.var_bad = " + var_bad + " (expected 2)\n");
           }
        }

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

        The problem is server compiler specific (32 and 64 bit).

              kvn Vladimir Kozlov
              epavlova Ekaterina Pavlova
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: