hotspot/test/runtime/logging/ClassInitializationTest.java
author mockner
Wed, 02 Dec 2015 14:07:58 -0500
changeset 34628 6d08ec72803b
child 35193 1e85994e9f56
permissions -rw-r--r--
8142976: Reimplement TraceClassInitialization with Unified Logging Summary: TraceClassInitialization logging reimplemented with Unified Logging. Reviewed-by: coleenp, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     1
/*
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
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
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    28
 * @library /testlibrary
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    29
 * @compile BadMap50.jasm
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    30
 * @run driver ClassInitializationTest
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    31
 */
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    32
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    33
import jdk.test.lib.*;
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    34
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    35
public class ClassInitializationTest {
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    36
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    37
    public static void main(String... args) throws Exception {
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    38
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    39
        // (1)
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    40
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:classinit=info", "-Xverify:all", "-Xmx64m", "BadMap50");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    41
        OutputAnalyzer out = new OutputAnalyzer(pb.start());
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    42
        out.shouldContain("Start class verification for:");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    43
        out.shouldContain("End class verification for:");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    44
        out.shouldContain("Initializing");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    45
        out.shouldContain("Verification for BadMap50 failed");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    46
        out.shouldContain("Fail over class verification to old verifier for: BadMap50");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    47
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    48
        // (2)
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    49
        if (Platform.isDebugBuild()) {
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    50
          pb = ProcessTools.createJavaProcessBuilder("-Xlog:classinit=info", "-Xverify:all", "-XX:+EagerInitialization", "-Xmx64m", "-version");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    51
          out = new OutputAnalyzer(pb.start());
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    52
          out.shouldContain("[Initialized").shouldContain("without side effects]");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    53
          out.shouldHaveExitValue(0);
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    54
        }
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    55
        // (3) Ensure that VerboseVerification still triggers appropriate messages.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    56
        pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:+VerboseVerification", "-Xverify:all", "-Xmx64m", "BadMap50");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    57
        out = new OutputAnalyzer(pb.start());
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    58
        out.shouldContain("End class verification for:");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    59
        out.shouldContain("Verification for BadMap50 failed");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    60
        out.shouldContain("Fail over class verification to old verifier for: BadMap50");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    61
    }
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    62
}