hotspot/test/runtime/logging/ClassInitializationTest.java
author dsamersoff
Sun, 01 May 2016 12:47:00 +0300
changeset 38152 80e5da81fb2c
parent 38151 fffedc5e5cf8
child 40631 ed82623d7831
permissions -rw-r--r--
8154258: [TESTBUG] Various serviceability tests fail compilation Summary: Replace sun.misc.Unsafe with jdk.internal.misc.Unsafe Reviewed-by: chegar, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     1
/*
35858
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     4
 *
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     8
 *
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    13
 * accompanied this code).
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    14
 *
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    18
 *
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    21
 * questions.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    22
 */
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    23
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    24
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    25
/*
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    26
 * @test ClassInitializationTest
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    27
 * @bug 8142976
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 38151
diff changeset
    28
 * @modules java.base/jdk.internal.misc
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    29
 * @library /testlibrary
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    30
 * @compile BadMap50.jasm
35193
1e85994e9f56 8145445: [TESTBUG] runtime/logging tests need to properly build and import libraries
rprotacio
parents: 34628
diff changeset
    31
 * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.Platform jdk.test.lib.ProcessTools
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    32
 * @run driver ClassInitializationTest
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    33
 */
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    34
35193
1e85994e9f56 8145445: [TESTBUG] runtime/logging tests need to properly build and import libraries
rprotacio
parents: 34628
diff changeset
    35
import jdk.test.lib.OutputAnalyzer;
1e85994e9f56 8145445: [TESTBUG] runtime/logging tests need to properly build and import libraries
rprotacio
parents: 34628
diff changeset
    36
import jdk.test.lib.Platform;
1e85994e9f56 8145445: [TESTBUG] runtime/logging tests need to properly build and import libraries
rprotacio
parents: 34628
diff changeset
    37
import jdk.test.lib.ProcessTools;
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    38
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    39
public class ClassInitializationTest {
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    40
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    41
    public static void main(String... args) throws Exception {
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    42
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    43
        // (1)
38151
fffedc5e5cf8 8154110: Update class* and safepoint* logging subsystems
mockner
parents: 37453
diff changeset
    44
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=info",
35858
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    45
                                                                  "-Xverify:all",
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    46
                                                                  "-Xmx64m",
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    47
                                                                  "BadMap50");
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    48
        OutputAnalyzer out = new OutputAnalyzer(pb.start());
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    49
        out.shouldContain("Start class verification for:");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    50
        out.shouldContain("End class verification for:");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    51
        out.shouldContain("Initializing");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    52
        out.shouldContain("Verification for BadMap50 failed");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    53
        out.shouldContain("Fail over class verification to old verifier for: BadMap50");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    54
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    55
        // (2)
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    56
        if (Platform.isDebugBuild()) {
38151
fffedc5e5cf8 8154110: Update class* and safepoint* logging subsystems
mockner
parents: 37453
diff changeset
    57
            pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=info",
35858
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    58
                                                       "-Xverify:all",
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    59
                                                       "-XX:+EagerInitialization",
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    60
                                                       "-Xmx64m",
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    61
                                                       InnerClass.class.getName());
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    62
            out = new OutputAnalyzer(pb.start());
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    63
            out.shouldContain("[Initialized").shouldContain("without side effects]");
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    64
            out.shouldHaveExitValue(0);
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    65
        }
37453
e333d1d43e75 8145704: Make test for classinit logging more robust.
mockner
parents: 37044
diff changeset
    66
38151
fffedc5e5cf8 8154110: Update class* and safepoint* logging subsystems
mockner
parents: 37453
diff changeset
    67
        // (3) class+init should turn off.
fffedc5e5cf8 8154110: Update class* and safepoint* logging subsystems
mockner
parents: 37453
diff changeset
    68
        pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=off",
37453
e333d1d43e75 8145704: Make test for classinit logging more robust.
mockner
parents: 37044
diff changeset
    69
                                                   "-Xverify:all",
e333d1d43e75 8145704: Make test for classinit logging more robust.
mockner
parents: 37044
diff changeset
    70
                                                   "-Xmx64m",
e333d1d43e75 8145704: Make test for classinit logging more robust.
mockner
parents: 37044
diff changeset
    71
                                                   "BadMap50");
e333d1d43e75 8145704: Make test for classinit logging more robust.
mockner
parents: 37044
diff changeset
    72
        out = new OutputAnalyzer(pb.start());
38151
fffedc5e5cf8 8154110: Update class* and safepoint* logging subsystems
mockner
parents: 37453
diff changeset
    73
        out.shouldNotContain("[class,init]");
37453
e333d1d43e75 8145704: Make test for classinit logging more robust.
mockner
parents: 37044
diff changeset
    74
        out.shouldNotContain("Fail over class verification to old verifier for: BadMap50");
e333d1d43e75 8145704: Make test for classinit logging more robust.
mockner
parents: 37044
diff changeset
    75
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    76
    }
35858
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    77
    public static class InnerClass {
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    78
        public static void main(String[] args) throws Exception {
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    79
            System.out.println("Inner Class");
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    80
        }
6e704583a38f 8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents: 35193
diff changeset
    81
    }
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    82
}