hotspot/test/runtime/Throwable/StackTraceLogging.java
author jdv
Tue, 09 Aug 2016 13:45:17 +0530
changeset 40432 6a878eae7459
parent 39397 ae63e0e7af71
child 40631 ed82623d7831
permissions -rw-r--r--
8160456: KSS : resource loading issue in TIFFMetadataFormat.java Reviewed-by: prr, bpb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37064
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
     1
/*
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
     4
 *
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
     8
 *
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    13
 * accompanied this code).
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    14
 *
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    18
 *
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    21
 * questions.
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    22
 */
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    23
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    24
/*
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    25
 * @test
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    26
 * @bug 8150778
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    27
 * @summary check stacktrace logging
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    28
 * @library /testlibrary
37298
8df0cc9da41e 8154028: Several hotspot tests need to be updated after 8153737 (Unsupported Module)
amurillo
parents: 37064
diff changeset
    29
 * @modules java.base/jdk.internal.misc
37064
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    30
 *          java.management
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    31
 * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    32
 * @compile TestThrowable.java
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    33
 * @run driver StackTraceLogging
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    34
 */
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    35
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    36
import java.io.File;
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    37
import java.util.Map;
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    38
import jdk.test.lib.OutputAnalyzer;
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    39
import jdk.test.lib.ProcessTools;
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    40
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    41
public class StackTraceLogging {
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    42
    static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    43
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
39397
ae63e0e7af71 8157592: StackTraceLogging fails with stack overflow on 32-bit Windows
gtriantafill
parents: 37298
diff changeset
    44
        // These depths match the ones in TestThrowable.java, except the one greater than 1024
ae63e0e7af71 8157592: StackTraceLogging fails with stack overflow on 32-bit Windows
gtriantafill
parents: 37298
diff changeset
    45
        int[] depths = {10, 34, 100, 1023, 1024};
37064
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    46
        for (int d : depths) {
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    47
            output.shouldContain("java.lang.RuntimeException, " + d);
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    48
        }
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    49
        output.shouldHaveExitValue(0);
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    50
    }
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    51
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    52
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    53
    public static void main(String[] args) throws Exception {
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    54
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:stacktrace=info",
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    55
                                                                  "-XX:MaxJavaStackTraceDepth=1024",
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    56
                                                                  "TestThrowable");
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    57
        analyzeOutputOn(pb);
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    58
    }
5c82fa70d313 8150778: Reduce Throwable.getStackTrace() calls to the JVM
coleenp
parents:
diff changeset
    59
}