test/compiler/stable/TestStableBoolean.java

Thu, 17 Apr 2014 16:09:08 -0700

author
amurillo
date
Thu, 17 Apr 2014 16:09:08 -0700
changeset 6635
49b5160951dd
parent 6528
248ff38d2950
child 6747
ee1c924763d2
permissions
-rw-r--r--

Added tag hs25.20-b11 for changeset b6a2ba7d3ea7

     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 TestStableBoolean
    28  * @summary tests on stable fields and arrays
    29  * @library /testlibrary
    30  * @compile -XDignore.symbol.file TestStableBoolean.java
    31  * @run main ClassFileInstaller
    32  *           java/lang/invoke/TestStableBoolean
    33  *           java/lang/invoke/TestStableBoolean$BooleanStable
    34  *           java/lang/invoke/TestStableBoolean$StaticBooleanStable
    35  *           java/lang/invoke/TestStableBoolean$VolatileBooleanStable
    36  *           java/lang/invoke/TestStableBoolean$BooleanArrayDim1
    37  *           java/lang/invoke/TestStableBoolean$BooleanArrayDim2
    38  *           java/lang/invoke/TestStableBoolean$BooleanArrayDim3
    39  *           java/lang/invoke/TestStableBoolean$BooleanArrayDim4
    40  *           java/lang/invoke/TestStableBoolean$ObjectArrayLowerDim0
    41  *           java/lang/invoke/TestStableBoolean$ObjectArrayLowerDim1
    42  *           java/lang/invoke/TestStableBoolean$NestedStableField
    43  *           java/lang/invoke/TestStableBoolean$NestedStableField$A
    44  *           java/lang/invoke/TestStableBoolean$NestedStableField1
    45  *           java/lang/invoke/TestStableBoolean$NestedStableField1$A
    46  *           java/lang/invoke/TestStableBoolean$NestedStableField2
    47  *           java/lang/invoke/TestStableBoolean$NestedStableField2$A
    48  *           java/lang/invoke/TestStableBoolean$NestedStableField3
    49  *           java/lang/invoke/TestStableBoolean$NestedStableField3$A
    50  *           java/lang/invoke/TestStableBoolean$DefaultValue
    51  *           java/lang/invoke/TestStableBoolean$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.TestStableBoolean
    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.TestStableBoolean
    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.TestStableBoolean
    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.TestStableBoolean
    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 TestStableBoolean {
    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(BooleanStable.class);
    91         run(StaticBooleanStable.class);
    92         run(VolatileBooleanStable.class);
    94         // @Stable arrays: Dim 1-4
    95         run(BooleanArrayDim1.class);
    96         run(BooleanArrayDim2.class);
    97         run(BooleanArrayDim3.class);
    98         run(BooleanArrayDim4.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 boolean v;
   121         public static final DefaultValue c = new DefaultValue();
   122         public static boolean get() { return c.v; }
   123         public static void test() throws Exception {
   124                         boolean val1 = get();
   125             c.v = true; boolean val2 = get();
   126             assertEquals(val1, false);
   127             assertEquals(val2, true);
   128         }
   129     }
   131     /* ==================================================== */
   133     static class BooleanStable {
   134         public @Stable boolean v;
   136         public static final BooleanStable c = new BooleanStable();
   137         public static boolean get() { return c.v; }
   138         public static void test() throws Exception {
   139             c.v = true; boolean val1 = get();
   140             c.v = false; boolean val2 = get();
   141             assertEquals(val1, true);
   142             assertEquals(val2, (isStableEnabled ? true : false));
   143         }
   144     }
   146     /* ==================================================== */
   148     static class StaticBooleanStable {
   149         public static @Stable boolean v;
   151         public static final StaticBooleanStable c = new StaticBooleanStable();
   152         public static boolean get() { return c.v; }
   153         public static void test() throws Exception {
   154             c.v = true; boolean val1 = get();
   155             c.v = false; boolean val2 = get();
   156             assertEquals(val1, true);
   157             assertEquals(val2, (isStableEnabled ? true : false));
   158         }
   159     }
   161     /* ==================================================== */
   163     static class VolatileBooleanStable {
   164         public @Stable volatile boolean v;
   166         public static final VolatileBooleanStable c = new VolatileBooleanStable();
   167         public static boolean get() { return c.v; }
   168         public static void test() throws Exception {
   169             c.v = true; boolean val1 = get();
   170             c.v = false; boolean val2 = get();
   171             assertEquals(val1, true);
   172             assertEquals(val2, (isStableEnabled ? true : false));
   173         }
   174     }
   176     /* ==================================================== */
   177     // @Stable array == field && all components are stable
   179     static class BooleanArrayDim1 {
   180         public @Stable boolean[] v;
   182         public static final BooleanArrayDim1 c = new BooleanArrayDim1();
   183         public static boolean get() { return c.v[0]; }
   184         public static boolean get1() { return c.v[10]; }
   185         public static boolean[] get2() { return c.v; }
   186         public static void test() throws Exception {
   187             {
   188                 c.v = new boolean[1]; c.v[0] = true;  boolean val1 = get();
   189                                       c.v[0] = false; boolean val2 = get();
   190                 assertEquals(val1, true);
   191                 assertEquals(val2, (isStableEnabled ? true : false));
   192             }
   194             {
   195                 c.v = new boolean[20]; c.v[10] = true;  boolean val1 = get1();
   196                                        c.v[10] = false; boolean val2 = get1();
   197                 assertEquals(val1, true);
   198                 assertEquals(val2, (isStableEnabled ? true : false));
   199             }
   201             {
   202                 c.v = new boolean[1]; boolean[] val1 = get2();
   203                 c.v = new boolean[1]; boolean[] val2 = get2();
   204                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   205             }
   206         }
   207     }
   209     /* ==================================================== */
   211     static class BooleanArrayDim2 {
   212         public @Stable boolean[][] v;
   214         public static final BooleanArrayDim2 c = new BooleanArrayDim2();
   215         public static boolean get() { return c.v[0][0]; }
   216         public static boolean[] get1() { return c.v[0]; }
   217         public static boolean[][] get2() { return c.v; }
   218         public static void test() throws Exception {
   219             {
   220                 c.v = new boolean[1][1]; c.v[0][0] = true;  boolean val1 = get();
   221                                          c.v[0][0] = false; boolean val2 = get();
   222                 assertEquals(val1, true);
   223                 assertEquals(val2, (isStableEnabled ? true : false));
   225                 c.v = new boolean[1][1]; c.v[0][0] = false; boolean val3 = get();
   226                 assertEquals(val3, (isStableEnabled ? true : false));
   228                 c.v[0] = new boolean[1]; c.v[0][0] = false; boolean val4 = get();
   229                 assertEquals(val4, (isStableEnabled ? true : false));
   230             }
   232             {
   233                 c.v = new boolean[1][1]; boolean[] val1 = get1();
   234                 c.v[0] = new boolean[1]; boolean[] val2 = get1();
   235                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   236             }
   238             {
   239                 c.v = new boolean[1][1]; boolean[][] val1 = get2();
   240                 c.v = new boolean[1][1]; boolean[][] val2 = get2();
   241                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   242             }
   243         }
   244     }
   246     /* ==================================================== */
   248     static class BooleanArrayDim3 {
   249         public @Stable boolean[][][] v;
   251         public static final BooleanArrayDim3 c = new BooleanArrayDim3();
   252         public static boolean get() { return c.v[0][0][0]; }
   253         public static boolean[] get1() { return c.v[0][0]; }
   254         public static boolean[][] get2() { return c.v[0]; }
   255         public static boolean[][][] get3() { return c.v; }
   256         public static void test() throws Exception {
   257             {
   258                 c.v = new boolean[1][1][1]; c.v[0][0][0] = true;  boolean val1 = get();
   259                                             c.v[0][0][0] = false; boolean val2 = get();
   260                 assertEquals(val1, true);
   261                 assertEquals(val2, (isStableEnabled ? true : false));
   263                 c.v = new boolean[1][1][1]; c.v[0][0][0] = false; boolean val3 = get();
   264                 assertEquals(val3, (isStableEnabled ? true : false));
   266                 c.v[0] = new boolean[1][1]; c.v[0][0][0] = false; boolean val4 = get();
   267                 assertEquals(val4, (isStableEnabled ? true : false));
   269                 c.v[0][0] = new boolean[1]; c.v[0][0][0] = false; boolean val5 = get();
   270                 assertEquals(val5, (isStableEnabled ? true : false));
   271             }
   273             {
   274                 c.v = new boolean[1][1][1]; boolean[] val1 = get1();
   275                 c.v[0][0] = new boolean[1]; boolean[] val2 = get1();
   276                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   277             }
   279             {
   280                 c.v = new boolean[1][1][1]; boolean[][] val1 = get2();
   281                 c.v[0] = new boolean[1][1]; boolean[][] val2 = get2();
   282                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   283             }
   285             {
   286                 c.v = new boolean[1][1][1]; boolean[][][] val1 = get3();
   287                 c.v = new boolean[1][1][1]; boolean[][][] val2 = get3();
   288                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   289             }
   290         }
   291     }
   293     /* ==================================================== */
   295     static class BooleanArrayDim4 {
   296         public @Stable boolean[][][][] v;
   298         public static final BooleanArrayDim4 c = new BooleanArrayDim4();
   299         public static boolean get() { return c.v[0][0][0][0]; }
   300         public static boolean[] get1() { return c.v[0][0][0]; }
   301         public static boolean[][] get2() { return c.v[0][0]; }
   302         public static boolean[][][] get3() { return c.v[0]; }
   303         public static boolean[][][][] get4() { return c.v; }
   304         public static void test() throws Exception {
   305             {
   306                 c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = true;  boolean val1 = get();
   307                                                c.v[0][0][0][0] = false; boolean val2 = get();
   308                 assertEquals(val1, true);
   309                 assertEquals(val2, (isStableEnabled ? true : false));
   311                 c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = false; boolean val3 = get();
   312                 assertEquals(val3, (isStableEnabled ? true : false));
   314                 c.v[0] = new boolean[1][1][1]; c.v[0][0][0][0] = false; boolean val4 = get();
   315                 assertEquals(val4, (isStableEnabled ? true : false));
   317                 c.v[0][0] = new boolean[1][1]; c.v[0][0][0][0] = false; boolean val5 = get();
   318                 assertEquals(val5, (isStableEnabled ? true : false));
   320                 c.v[0][0][0] = new boolean[1]; c.v[0][0][0][0] = false; boolean val6 = get();
   321                 assertEquals(val6, (isStableEnabled ? true : false));
   322             }
   324             {
   325                 c.v = new boolean[1][1][1][1]; boolean[] val1 = get1();
   326                 c.v[0][0][0] = new boolean[1]; boolean[] val2 = get1();
   327                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   328             }
   330             {
   331                 c.v = new boolean[1][1][1][1]; boolean[][] val1 = get2();
   332                 c.v[0][0] = new boolean[1][1]; boolean[][] val2 = get2();
   333                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   334             }
   336             {
   337                 c.v = new boolean[1][1][1][1]; boolean[][][] val1 = get3();
   338                 c.v[0] = new boolean[1][1][1]; boolean[][][] val2 = get3();
   339                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   340             }
   342             {
   343                 c.v = new boolean[1][1][1][1]; boolean[][][][] val1 = get4();
   344                 c.v = new boolean[1][1][1][1]; boolean[][][][] val2 = get4();
   345                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   346             }
   348         }
   349     }
   351     /* ==================================================== */
   352     // Dynamic Dim is higher than static
   354     static class ObjectArrayLowerDim0 {
   355         public @Stable Object v;
   357         public static final ObjectArrayLowerDim0 c = new ObjectArrayLowerDim0();
   358         public static boolean get() { return ((boolean[])c.v)[0]; }
   359         public static boolean[] get1() { return (boolean[])c.v; }
   360         public static boolean[] get2() { return (boolean[])c.v; }
   362         public static void test() throws Exception {
   363             {
   364                 c.v = new boolean[1]; ((boolean[])c.v)[0] = true;  boolean val1 = get();
   365                                       ((boolean[])c.v)[0] = false; boolean val2 = get();
   367                 assertEquals(val1, true);
   368                 assertEquals(val2, false);
   369             }
   371             {
   372                 c.v = new boolean[1]; boolean[] val1 = get1();
   373                 c.v = new boolean[1]; boolean[] val2 = get1();
   374                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   375             }
   376         }
   377     }
   379     /* ==================================================== */
   381     static class ObjectArrayLowerDim1 {
   382         public @Stable Object[] v;
   384         public static final ObjectArrayLowerDim1 c = new ObjectArrayLowerDim1();
   385         public static boolean get() { return ((boolean[][])c.v)[0][0]; }
   386         public static boolean[] get1() { return (boolean[])(c.v[0]); }
   387         public static Object[] get2() { return c.v; }
   389         public static void test() throws Exception {
   390             {
   391                 c.v = new boolean[1][1]; ((boolean[][])c.v)[0][0] = true;  boolean val1 = get();
   392                                          ((boolean[][])c.v)[0][0] = false; boolean val2 = get();
   394                 assertEquals(val1, true);
   395                 assertEquals(val2, false);
   396             }
   398             {
   399                 c.v = new boolean[1][1]; c.v[0] = new boolean[0]; boolean[] val1 = get1();
   400                                          c.v[0] = new boolean[0]; boolean[] val2 = get1();
   402                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   403             }
   405             {
   406                 c.v = new boolean[0][0]; Object[] val1 = get2();
   407                 c.v = new boolean[0][0]; Object[] val2 = get2();
   409                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   410             }
   411         }
   412     }
   414     /* ==================================================== */
   416     static class ObjectArrayLowerDim2 {
   417         public @Stable Object[][] v;
   419         public static final ObjectArrayLowerDim2 c = new ObjectArrayLowerDim2();
   420         public static boolean get() { return ((boolean[][][])c.v)[0][0][0]; }
   421         public static boolean[] get1() { return (boolean[])(c.v[0][0]); }
   422         public static boolean[][] get2() { return (boolean[][])(c.v[0]); }
   423         public static Object[][] get3() { return c.v; }
   425         public static void test() throws Exception {
   426             {
   427                 c.v = new boolean[1][1][1]; ((boolean[][][])c.v)[0][0][0] = true;  boolean val1 = get();
   428                                             ((boolean[][][])c.v)[0][0][0] = false; boolean val2 = get();
   430                 assertEquals(val1, true);
   431                 assertEquals(val2, false);
   432             }
   434             {
   435                 c.v = new boolean[1][1][1]; c.v[0][0] = new boolean[0]; boolean[] val1 = get1();
   436                                             c.v[0][0] = new boolean[0]; boolean[] val2 = get1();
   438                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   439             }
   441             {
   442                 c.v = new boolean[1][1][1]; c.v[0] = new boolean[0][0]; boolean[][] val1 = get2();
   443                                             c.v[0] = new boolean[0][0]; boolean[][] val2 = get2();
   445                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   446             }
   448             {
   449                 c.v = new boolean[0][0][0]; Object[][] val1 = get3();
   450                 c.v = new boolean[0][0][0]; Object[][] val2 = get3();
   452                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
   453             }
   454         }
   455     }
   457     /* ==================================================== */
   459     static class NestedStableField {
   460         static class A {
   461             public @Stable boolean a;
   463         }
   464         public @Stable A v;
   466         public static final NestedStableField c = new NestedStableField();
   467         public static A get() { return c.v; }
   468         public static boolean get1() { return get().a; }
   470         public static void test() throws Exception {
   471             {
   472                 c.v = new A(); c.v.a = true;  A val1 = get();
   473                                c.v.a = false; A val2 = get();
   475                 assertEquals(val1.a, false);
   476                 assertEquals(val2.a, false);
   477             }
   479             {
   480                 c.v = new A(); c.v.a = true;  boolean val1 = get1();
   481                                c.v.a = false; boolean val2 = get1();
   482                 c.v = new A(); c.v.a = false; boolean val3 = get1();
   484                 assertEquals(val1, true);
   485                 assertEquals(val2, (isStableEnabled ? true : false));
   486                 assertEquals(val3, (isStableEnabled ? true : false));
   487             }
   488         }
   489     }
   491     /* ==================================================== */
   493     static class NestedStableField1 {
   494         static class A {
   495             public @Stable boolean a;
   496             public @Stable A next;
   497         }
   498         public @Stable A v;
   500         public static final NestedStableField1 c = new NestedStableField1();
   501         public static A get() { return c.v.next.next.next.next.next.next.next; }
   502         public static boolean get1() { return get().a; }
   504         public static void test() throws Exception {
   505             {
   506                 c.v = new A(); c.v.next = new A(); c.v.next.next  = c.v;
   507                                c.v.a = true;  c.v.next.a = true;  A val1 = get();
   508                                c.v.a = false; c.v.next.a = false; A val2 = get();
   510                 assertEquals(val1.a, false);
   511                 assertEquals(val2.a, false);
   512             }
   514             {
   515                 c.v = new A(); c.v.next = c.v;
   516                                c.v.a = true;  boolean val1 = get1();
   517                                c.v.a = false; boolean val2 = get1();
   518                 c.v = new A(); c.v.next = c.v;
   519                                c.v.a = false; boolean val3 = get1();
   521                 assertEquals(val1, true);
   522                 assertEquals(val2, (isStableEnabled ? true : false));
   523                 assertEquals(val3, (isStableEnabled ? true : false));
   524             }
   525         }
   526     }
   527    /* ==================================================== */
   529     static class NestedStableField2 {
   530         static class A {
   531             public @Stable boolean a;
   532             public @Stable A left;
   533             public         A right;
   534         }
   536         public @Stable A v;
   538         public static final NestedStableField2 c = new NestedStableField2();
   539         public static boolean get() { return c.v.left.left.left.a; }
   540         public static boolean get1() { return c.v.left.left.right.left.a; }
   542         public static void test() throws Exception {
   543             {
   544                 c.v = new A(); c.v.left = c.v.right = c.v;
   545                                c.v.a = true;  boolean val1 = get(); boolean val2 = get1();
   546                                c.v.a = false; boolean val3 = get(); boolean val4 = get1();
   548                 assertEquals(val1, true);
   549                 assertEquals(val3, (isStableEnabled ? true : false));
   551                 assertEquals(val2, true);
   552                 assertEquals(val4, false);
   553             }
   554         }
   555     }
   557     /* ==================================================== */
   559     static class NestedStableField3 {
   560         static class A {
   561             public @Stable boolean a;
   562             public @Stable A[] left;
   563             public         A[] right;
   564         }
   566         public @Stable A[] v;
   568         public static final NestedStableField3 c = new NestedStableField3();
   569         public static boolean get() { return c.v[0].left[1].left[0].left[1].a; }
   570         public static boolean get1() { return c.v[1].left[0].left[1].right[0].left[1].a; }
   572         public static void test() throws Exception {
   573             {
   574                 A elem = new A();
   575                 c.v = new A[] { elem, elem }; c.v[0].left = c.v[0].right = c.v;
   576                                elem.a = true;  boolean val1 = get(); boolean val2 = get1();
   577                                elem.a = false; boolean val3 = get(); boolean val4 = get1();
   579                 assertEquals(val1, true);
   580                 assertEquals(val3, (isStableEnabled ? true : false));
   582                 assertEquals(val2, true);
   583                 assertEquals(val4, false);
   584             }
   585         }
   586     }
   588     /* ==================================================== */
   589     // Auxiliary methods
   590     static void assertEquals(boolean i, boolean j) { if (i != j)  throw new AssertionError(i + " != " + j); }
   591     static void assertTrue(boolean b) { if (!b)  throw new AssertionError(); }
   593     static boolean failed = false;
   595     public static void run(Class<?> test) {
   596         Throwable ex = null;
   597         System.out.print(test.getName()+": ");
   598         try {
   599             test.getMethod("test").invoke(null);
   600         } catch (InvocationTargetException e) {
   601             ex = e.getCause();
   602         } catch (Throwable e) {
   603             ex = e;
   604         } finally {
   605             if (ex == null) {
   606                 System.out.println("PASSED");
   607             } else {
   608                 failed = true;
   609                 System.out.println("FAILED");
   610                 ex.printStackTrace(System.out);
   611             }
   612         }
   613     }
   615     static final boolean isStableEnabled;
   616     static {
   617         HotSpotDiagnosticMXBean diagnostic
   618                 = ManagementFactoryHelper.getDiagnosticMXBean();
   619         VMOption tmp;
   620         try {
   621             tmp = diagnostic.getVMOption("FoldStableValues");
   622         } catch (IllegalArgumentException e) {
   623             tmp = null;
   624         }
   625         isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
   626     }
   627 }

mercurial