test/compiler/stable/TestStableChar.java

Wed, 21 May 2014 10:56:41 -0700

author
katleman
date
Wed, 21 May 2014 10:56:41 -0700
changeset 6672
fb9d124d9192
parent 6528
248ff38d2950
child 6747
ee1c924763d2
permissions
-rw-r--r--

Added tag jdk8u20-b15 for changeset 8c785f9bde6f

     1 /*
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 /*
    27  * @test TestStableChar
    28  * @summary tests on stable fields and arrays
    29  * @library /testlibrary
    30  * @compile -XDignore.symbol.file TestStableChar.java
    31  * @run main ClassFileInstaller
    32  *           java/lang/invoke/TestStableChar
    33  *           java/lang/invoke/TestStableChar$CharStable
    34  *           java/lang/invoke/TestStableChar$StaticCharStable
    35  *           java/lang/invoke/TestStableChar$VolatileCharStable
    36  *           java/lang/invoke/TestStableChar$CharArrayDim1
    37  *           java/lang/invoke/TestStableChar$CharArrayDim2
    38  *           java/lang/invoke/TestStableChar$CharArrayDim3
    39  *           java/lang/invoke/TestStableChar$CharArrayDim4
    40  *           java/lang/invoke/TestStableChar$ObjectArrayLowerDim0
    41  *           java/lang/invoke/TestStableChar$ObjectArrayLowerDim1
    42  *           java/lang/invoke/TestStableChar$NestedStableField
    43  *           java/lang/invoke/TestStableChar$NestedStableField$A
    44  *           java/lang/invoke/TestStableChar$NestedStableField1
    45  *           java/lang/invoke/TestStableChar$NestedStableField1$A
    46  *           java/lang/invoke/TestStableChar$NestedStableField2
    47  *           java/lang/invoke/TestStableChar$NestedStableField2$A
    48  *           java/lang/invoke/TestStableChar$NestedStableField3
    49  *           java/lang/invoke/TestStableChar$NestedStableField3$A
    50  *           java/lang/invoke/TestStableChar$DefaultValue
    51  *           java/lang/invoke/TestStableChar$ObjectArrayLowerDim2
    52  *
    53  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
    54  *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
    55  *                   -server -XX:-TieredCompilation -Xcomp
    56  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
    57  *                   java.lang.invoke.TestStableChar
    58  *
    59  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
    60  *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
    61  *                   -server -XX:-TieredCompilation -Xcomp
    62  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
    63  *                   java.lang.invoke.TestStableChar
    64  *
    65  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
    66  *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
    67  *                   -server -XX:-TieredCompilation -Xcomp
    68  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
    69  *                   java.lang.invoke.TestStableChar
    70  *
    71  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
    72  *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
    73  *                   -server -XX:-TieredCompilation -Xcomp
    74  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
    75  *                   java.lang.invoke.TestStableChar
    76  */
    77 package java.lang.invoke;
    79 import com.sun.management.HotSpotDiagnosticMXBean;
    80 import com.sun.management.VMOption;
    81 import sun.management.ManagementFactoryHelper;
    82 import java.lang.reflect.InvocationTargetException;
    84 public class TestStableChar {
    85     public static void main(String[] args) throws Exception {
    86         System.out.println("@Stable enabled: "+isStableEnabled);
    87         System.out.println();
    89         run(DefaultValue.class);
    90         run(CharStable.class);
    91         run(StaticCharStable.class);
    92         run(VolatileCharStable.class);
    94         // @Stable arrays: Dim 1-4
    95         run(CharArrayDim1.class);
    96         run(CharArrayDim2.class);
    97         run(CharArrayDim3.class);
    98         run(CharArrayDim4.class);
   100         // @Stable Object field: dynamic arrays
   101         run(ObjectArrayLowerDim0.class);
   102         run(ObjectArrayLowerDim1.class);
   103         run(ObjectArrayLowerDim2.class);
   105         // Nested @Stable fields
   106         run(NestedStableField.class);
   107         run(NestedStableField1.class);
   108         run(NestedStableField2.class);
   109         run(NestedStableField3.class);
   111         if (failed) {
   112             throw new Error("TEST FAILED");
   113         }
   114     }
   116     /* ==================================================== */
   118     static class DefaultValue {
   119         public @Stable char v;
   121         public static final DefaultValue c = new DefaultValue();
   122         public static char get() { return c.v; }
   123         public static void test() throws Exception {
   124                        char val1 = get();
   125             c.v = 'a'; char val2 = get();
   126             assertEquals(val1, 0);
   127             assertEquals(val2, 'a');
   128         }
   129     }
   131     /* ==================================================== */
   133     static class CharStable {
   134         public @Stable char v;
   136         public static final CharStable c = new CharStable();
   137         public static char get() { return c.v; }
   138         public static void test() throws Exception {
   139             c.v = 'a'; char val1 = get();
   140             c.v = 'b'; char val2 = get();
   141             assertEquals(val1, 'a');
   142             assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
   143         }
   144     }
   146     /* ==================================================== */
   148     static class StaticCharStable {
   149         public @Stable char v;
   151         public static final StaticCharStable c = new StaticCharStable();
   152         public static char get() { return c.v; }
   153         public static void test() throws Exception {
   154             c.v = 'a'; char val1 = get();
   155             c.v = 'b'; char val2 = get();
   156             assertEquals(val1, 'a');
   157             assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
   158         }
   159     }
   161     /* ==================================================== */
   163     static class VolatileCharStable {
   164         public @Stable volatile char v;
   166         public static final VolatileCharStable c = new VolatileCharStable();
   167         public static char get() { return c.v; }
   168         public static void test() throws Exception {
   169             c.v = 'a'; char val1 = get();
   170             c.v = 'b'; char val2 = get();
   171             assertEquals(val1, 'a');
   172             assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
   173         }
   174     }
   176     /* ==================================================== */
   177     // @Stable array == field && all components are stable
   179     static class CharArrayDim1 {
   180         public @Stable char[] v;
   182         public static final CharArrayDim1 c = new CharArrayDim1();
   183         public static char get() { return c.v[0]; }
   184         public static char get1() { return c.v[10]; }
   185         public static char[] get2() { return c.v; }
   186         public static void test() throws Exception {
   187             {
   188                 c.v = new char[1]; c.v[0] = 'a'; char val1 = get();
   189                                    c.v[0] = 'b'; char val2 = get();
   190                 assertEquals(val1, 'a');
   191                 assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
   193                 c.v = new char[1]; c.v[0] = 'c'; char val3 = get();
   194                 assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
   195             }
   197             {
   198                 c.v = new char[20]; c.v[10] = 'a'; char val1 = get1();
   199                                     c.v[10] = 'b'; char val2 = get1();
   200                 assertEquals(val1, 'a');
   201                 assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
   203                 c.v = new char[20]; c.v[10] = 'c'; char val3 = get1();
   204                 assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
   205             }
   207             {
   208                 c.v = new char[1]; char[] val1 = get2();
   209                 c.v = new char[1]; char[] val2 = get2();
   210                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   211             }
   212         }
   213     }
   215     /* ==================================================== */
   217     static class CharArrayDim2 {
   218         public @Stable char[][] v;
   220         public static final CharArrayDim2 c = new CharArrayDim2();
   221         public static char get() { return c.v[0][0]; }
   222         public static char[] get1() { return c.v[0]; }
   223         public static char[][] get2() { return c.v; }
   224         public static void test() throws Exception {
   225             {
   226                 c.v = new char[1][1]; c.v[0][0] = 'a'; char val1 = get();
   227                                       c.v[0][0] = 'b'; char val2 = get();
   228                 assertEquals(val1, 'a');
   229                 assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
   231                 c.v = new char[1][1]; c.v[0][0] = 'c'; char val3 = get();
   232                 assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
   234                 c.v[0] = new char[1]; c.v[0][0] = 'd'; char val4 = get();
   235                 assertEquals(val4, (isStableEnabled ? 'a' : 'd'));
   236             }
   238             {
   239                 c.v = new char[1][1]; char[] val1 = get1();
   240                 c.v[0] = new char[1]; char[] val2 = get1();
   241                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   242             }
   244             {
   245                 c.v = new char[1][1]; char[][] val1 = get2();
   246                 c.v = new char[1][1]; char[][] val2 = get2();
   247                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   248             }
   249         }
   250     }
   252     /* ==================================================== */
   254     static class CharArrayDim3 {
   255         public @Stable char[][][] v;
   257         public static final CharArrayDim3 c = new CharArrayDim3();
   258         public static char get() { return c.v[0][0][0]; }
   259         public static char[] get1() { return c.v[0][0]; }
   260         public static char[][] get2() { return c.v[0]; }
   261         public static char[][][] get3() { return c.v; }
   262         public static void test() throws Exception {
   263             {
   264                 c.v = new char[1][1][1]; c.v[0][0][0] = 'a'; char val1 = get();
   265                                          c.v[0][0][0] = 'b'; char val2 = get();
   266                 assertEquals(val1, 'a');
   267                 assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
   269                 c.v = new char[1][1][1]; c.v[0][0][0] = 'c'; char val3 = get();
   270                 assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
   272                 c.v[0] = new char[1][1]; c.v[0][0][0] = 'd'; char val4 = get();
   273                 assertEquals(val4, (isStableEnabled ? 'a' : 'd'));
   275                 c.v[0][0] = new char[1]; c.v[0][0][0] = 'e'; char val5 = get();
   276                 assertEquals(val5, (isStableEnabled ? 'a' : 'e'));
   277             }
   279             {
   280                 c.v = new char[1][1][1]; char[] val1 = get1();
   281                 c.v[0][0] = new char[1]; char[] val2 = get1();
   282                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   283             }
   285             {
   286                 c.v = new char[1][1][1]; char[][] val1 = get2();
   287                 c.v[0] = new char[1][1]; char[][] val2 = get2();
   288                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   289             }
   291             {
   292                 c.v = new char[1][1][1]; char[][][] val1 = get3();
   293                 c.v = new char[1][1][1]; char[][][] val2 = get3();
   294                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   295             }
   296         }
   297     }
   299     /* ==================================================== */
   301     static class CharArrayDim4 {
   302         public @Stable char[][][][] v;
   304         public static final CharArrayDim4 c = new CharArrayDim4();
   305         public static char get() { return c.v[0][0][0][0]; }
   306         public static char[] get1() { return c.v[0][0][0]; }
   307         public static char[][] get2() { return c.v[0][0]; }
   308         public static char[][][] get3() { return c.v[0]; }
   309         public static char[][][][] get4() { return c.v; }
   310         public static void test() throws Exception {
   311             {
   312                 c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'a'; char val1 = get();
   313                                             c.v[0][0][0][0] = 'b'; char val2 = get();
   314                 assertEquals(val1, 'a');
   315                 assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
   317                 c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'c'; char val3 = get();
   318                 assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
   320                 c.v[0] = new char[1][1][1]; c.v[0][0][0][0] = 'd'; char val4 = get();
   321                 assertEquals(val4, (isStableEnabled ? 'a' : 'd'));
   323                 c.v[0][0] = new char[1][1]; c.v[0][0][0][0] = 'e'; char val5 = get();
   324                 assertEquals(val5, (isStableEnabled ? 'a' : 'e'));
   326                 c.v[0][0][0] = new char[1]; c.v[0][0][0][0] = 'f'; char val6 = get();
   327                 assertEquals(val6, (isStableEnabled ? 'a' : 'f'));
   328             }
   330             {
   331                 c.v = new char[1][1][1][1]; char[] val1 = get1();
   332                 c.v[0][0][0] = new char[1]; char[] val2 = get1();
   333                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   334             }
   336             {
   337                 c.v = new char[1][1][1][1]; char[][] val1 = get2();
   338                 c.v[0][0] = new char[1][1]; char[][] val2 = get2();
   339                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   340             }
   342             {
   343                 c.v = new char[1][1][1][1]; char[][][] val1 = get3();
   344                 c.v[0] = new char[1][1][1]; char[][][] val2 = get3();
   345                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   346             }
   348             {
   349                 c.v = new char[1][1][1][1]; char[][][][] val1 = get4();
   350                 c.v = new char[1][1][1][1]; char[][][][] val2 = get4();
   351                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   352             }
   354         }
   355     }
   357     /* ==================================================== */
   358     // Dynamic Dim is higher than static
   359     static class ObjectArrayLowerDim0 {
   360         public @Stable Object v;
   362         public static final ObjectArrayLowerDim0 c = new ObjectArrayLowerDim0();
   363         public static char get() { return ((char[])c.v)[0]; }
   364         public static char[] get1() { return (char[])c.v; }
   366         public static void test() throws Exception {
   367             {
   368                 c.v = new char[1]; ((char[])c.v)[0] = 'a'; char val1 = get();
   369                                    ((char[])c.v)[0] = 'b'; char val2 = get();
   371                 assertEquals(val1, 'a');
   372                 assertEquals(val2, 'b');
   373             }
   375             {
   376                 c.v = new char[1]; char[] val1 = get1();
   377                 c.v = new char[1]; char[] val2 = get1();
   378                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   379             }
   380         }
   381     }
   383     /* ==================================================== */
   385     static class ObjectArrayLowerDim1 {
   386         public @Stable Object[] v;
   388         public static final ObjectArrayLowerDim1 c = new ObjectArrayLowerDim1();
   389         public static char get() { return ((char[][])c.v)[0][0]; }
   390         public static char[] get1() { return (char[])(c.v[0]); }
   391         public static Object[] get2() { return c.v; }
   393         public static void test() throws Exception {
   394             {
   395                 c.v = new char[1][1]; ((char[][])c.v)[0][0] = 'a'; char val1 = get();
   396                                       ((char[][])c.v)[0][0] = 'b'; char val2 = get();
   398                 assertEquals(val1, 'a');
   399                 assertEquals(val2, 'b');
   400             }
   402             {
   403                 c.v = new char[1][1]; c.v[0] = new char[0]; char[] val1 = get1();
   404                                       c.v[0] = new char[0]; char[] val2 = get1();
   406                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   407             }
   409             {
   410                 c.v = new char[0][0]; Object[] val1 = get2();
   411                 c.v = new char[0][0]; Object[] val2 = get2();
   413                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   414             }
   415         }
   416     }
   418     /* ==================================================== */
   420     static class ObjectArrayLowerDim2 {
   421         public @Stable Object[][] v;
   423         public static final ObjectArrayLowerDim2 c = new ObjectArrayLowerDim2();
   424         public static char get() { return ((char[][][])c.v)[0][0][0]; }
   425         public static char[] get1() { return (char[])(c.v[0][0]); }
   426         public static char[][] get2() { return (char[][])(c.v[0]); }
   427         public static Object[][] get3() { return c.v; }
   429         public static void test() throws Exception {
   430             {
   431                 c.v = new char[1][1][1]; ((char[][][])c.v)[0][0][0] = 'a';  char val1 = get();
   432                                          ((char[][][])c.v)[0][0][0] = 'b'; char val2 = get();
   434                 assertEquals(val1, 'a');
   435                 assertEquals(val2, 'b');
   436             }
   438             {
   439                 c.v = new char[1][1][1]; c.v[0][0] = new char[0]; char[] val1 = get1();
   440                                          c.v[0][0] = new char[0]; char[] val2 = get1();
   442                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   443             }
   445             {
   446                 c.v = new char[1][1][1]; c.v[0] = new char[0][0]; char[][] val1 = get2();
   447                                          c.v[0] = new char[0][0]; char[][] val2 = get2();
   449                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   450             }
   452             {
   453                 c.v = new char[0][0][0]; Object[][] val1 = get3();
   454                 c.v = new char[0][0][0]; Object[][] val2 = get3();
   456                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   457             }
   458         }
   459     }
   461     /* ==================================================== */
   463     static class NestedStableField {
   464         static class A {
   465             public @Stable char a;
   467         }
   468         public @Stable A v;
   470         public static final NestedStableField c = new NestedStableField();
   471         public static A get() { return c.v; }
   472         public static char get1() { return get().a; }
   474         public static void test() throws Exception {
   475             {
   476                 c.v = new A(); c.v.a = 'a'; A val1 = get();
   477                                c.v.a = 'b'; A val2 = get();
   479                 assertEquals(val1.a, 'b');
   480                 assertEquals(val2.a, 'b');
   481             }
   483             {
   484                 c.v = new A(); c.v.a = 'a'; char val1 = get1();
   485                                c.v.a = 'b'; char val2 = get1();
   486                 c.v = new A(); c.v.a = 'c'; char val3 = get1();
   488                 assertEquals(val1, 'a');
   489                 assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
   490                 assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
   491             }
   492         }
   493     }
   495     /* ==================================================== */
   497     static class NestedStableField1 {
   498         static class A {
   499             public @Stable char a;
   500             public @Stable A next;
   501         }
   502         public @Stable A v;
   504         public static final NestedStableField1 c = new NestedStableField1();
   505         public static A get() { return c.v.next.next.next.next.next.next.next; }
   506         public static char get1() { return get().a; }
   508         public static void test() throws Exception {
   509             {
   510                 c.v = new A(); c.v.next = new A(); c.v.next.next  = c.v;
   511                                c.v.a = 'a'; c.v.next.a = 'a'; A val1 = get();
   512                                c.v.a = 'b'; c.v.next.a = 'b'; A val2 = get();
   514                 assertEquals(val1.a, 'b');
   515                 assertEquals(val2.a, 'b');
   516             }
   518             {
   519                 c.v = new A(); c.v.next = c.v;
   520                                c.v.a = 'a'; char val1 = get1();
   521                                c.v.a = 'b'; char val2 = get1();
   522                 c.v = new A(); c.v.next = c.v;
   523                                c.v.a = 'c'; char val3 = get1();
   525                 assertEquals(val1, 'a');
   526                 assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
   527                 assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
   528             }
   529         }
   530     }
   531    /* ==================================================== */
   533     static class NestedStableField2 {
   534         static class A {
   535             public @Stable char a;
   536             public @Stable A left;
   537             public         A right;
   538         }
   540         public @Stable A v;
   542         public static final NestedStableField2 c = new NestedStableField2();
   543         public static char get() { return c.v.left.left.left.a; }
   544         public static char get1() { return c.v.left.left.right.left.a; }
   546         public static void test() throws Exception {
   547             {
   548                 c.v = new A(); c.v.left = c.v.right = c.v;
   549                                c.v.a = 'a'; char val1 = get(); char val2 = get1();
   550                                c.v.a = 'b'; char val3 = get(); char val4 = get1();
   552                 assertEquals(val1, 'a');
   553                 assertEquals(val3, (isStableEnabled ? 'a' : 'b'));
   555                 assertEquals(val2, 'a');
   556                 assertEquals(val4, 'b');
   557             }
   558         }
   559     }
   561     /* ==================================================== */
   563     static class NestedStableField3 {
   564         static class A {
   565             public @Stable char a;
   566             public @Stable A[] left;
   567             public         A[] right;
   568         }
   570         public @Stable A[] v;
   572         public static final NestedStableField3 c = new NestedStableField3();
   573         public static char get() { return c.v[0].left[1].left[0].left[1].a; }
   574         public static char get1() { return c.v[1].left[0].left[1].right[0].left[1].a; }
   576         public static void test() throws Exception {
   577             {
   578                 A elem = new A();
   579                 c.v = new A[] { elem, elem }; c.v[0].left = c.v[0].right = c.v;
   580                                elem.a = 'a'; char val1 = get(); char val2 = get1();
   581                                elem.a = 'b'; char val3 = get(); char val4 = get1();
   583                 assertEquals(val1, 'a');
   584                 assertEquals(val3, (isStableEnabled ? 'a' : 'b'));
   586                 assertEquals(val2, 'a');
   587                 assertEquals(val4, 'b');
   588             }
   589         }
   590     }
   592     /* ==================================================== */
   593     // Auxiliary methods
   594     static void assertEquals(int i, int j) { if (i != j)  throw new AssertionError(i + " != " + j); }
   595     static void assertTrue(boolean b) { if (!b)  throw new AssertionError(); }
   597     static boolean failed = false;
   599     public static void run(Class<?> test) {
   600         Throwable ex = null;
   601         System.out.print(test.getName()+": ");
   602         try {
   603             test.getMethod("test").invoke(null);
   604         } catch (InvocationTargetException e) {
   605             ex = e.getCause();
   606         } catch (Throwable e) {
   607             ex = e;
   608         } finally {
   609             if (ex == null) {
   610                 System.out.println("PASSED");
   611             } else {
   612                 failed = true;
   613                 System.out.println("FAILED");
   614                 ex.printStackTrace(System.out);
   615             }
   616         }
   617     }
   619     static final boolean isStableEnabled;
   620     static {
   621         HotSpotDiagnosticMXBean diagnostic
   622                 = ManagementFactoryHelper.getDiagnosticMXBean();
   623         VMOption tmp;
   624         try {
   625             tmp = diagnostic.getVMOption("FoldStableValues");
   626         } catch (IllegalArgumentException e) {
   627             tmp = null;
   628         }
   629         isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
   630     }
   631 }

mercurial