test/gc/6941923/Test6941923.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 6198
55fb97c4c58d
child 6876
710a3c8b516e
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

     1 /*
     2  * Copyright (c) 2012, 2013, 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.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test Test6941923.java
    26  * @bug 6941923
    27  * @summary test flags for gc log rotation
    28  * @library /testlibrary
    29  * @run main/othervm/timeout=600 Test6941923
    30  *
    31  */
    32 import com.oracle.java.testlibrary.*;
    33 import java.io.File;
    34 import java.io.FilenameFilter;
    35 import java.util.ArrayList;
    36 import java.util.Arrays;
    38 class GCLoggingGenerator {
    40     public static void main(String[] args) throws Exception {
    42         long sizeOfLog = Long.parseLong(args[0]);
    43         long lines = sizeOfLog / 80;
    44         // full.GC generates ad least 1-line which is not shorter then 80 chars
    45         // for some GC 2 shorter lines are generated
    46         for (long i = 0; i < lines; i++) {
    47             System.gc();
    48         }
    49     }
    50 }
    52 public class Test6941923 {
    54     static final File currentDirectory = new File(".");
    55     static final String logFileName = "test.log";
    56     static final int logFileSizeK = 16;
    57     static FilenameFilter logFilter = new FilenameFilter() {
    58         @Override
    59         public boolean accept(File dir, String name) {
    60             return name.startsWith(logFileName);
    61         }
    62     };
    64     public static void cleanLogs() {
    65         for (File log : currentDirectory.listFiles(logFilter)) {
    66             if (!log.delete()) {
    67                 throw new Error("Unable to delete " + log.getAbsolutePath());
    68             }
    69         }
    70     }
    72     public static void runTest(int numberOfFiles) throws Exception {
    74         ArrayList<String> args = new ArrayList();
    75         String[] logOpts = new String[]{
    76             "-cp", System.getProperty("java.class.path"),
    77             "-Xloggc:" + logFileName,
    78             "-XX:-DisableExplicitGC", // to sure that System.gc() works
    79             "-XX:+PrintGC", "-XX:+PrintGCDetails", "-XX:+UseGCLogFileRotation",
    80             "-XX:NumberOfGCLogFiles=" + numberOfFiles,
    81             "-XX:GCLogFileSize=" + logFileSizeK + "K", "-Xmx128M"};
    82         // System.getProperty("test.java.opts") is '' if no options is set
    83         // need to skip such empty
    84         String[] externalVMopts = System.getProperty("test.java.opts").length() == 0
    85                 ? new String[0]
    86                 : System.getProperty("test.java.opts").split(" ");
    87         args.addAll(Arrays.asList(externalVMopts));
    88         args.addAll(Arrays.asList(logOpts));
    89         args.add(GCLoggingGenerator.class.getName());
    90         args.add(String.valueOf(numberOfFiles * logFileSizeK * 1024));
    91         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[0]));
    92         pb.redirectErrorStream(true);
    93         pb.redirectOutput(new File(GCLoggingGenerator.class.getName() + ".log"));
    94         Process process = pb.start();
    95         int result = process.waitFor();
    96         if (result != 0) {
    97             throw new Error("Unexpected exit code = " + result);
    98         }
    99         File[] logs = currentDirectory.listFiles(logFilter);
   100         int smallFilesNumber = 0;
   101         for (File log : logs) {
   102             if (log.length() < logFileSizeK * 1024) {
   103                 smallFilesNumber++;
   104             }
   105         }
   106         if (logs.length != numberOfFiles) {
   107             throw new Error("There are only " + logs.length + " logs instead " + numberOfFiles);
   108         }
   109         if (smallFilesNumber > 1) {
   110             throw new Error("There should maximum one log with size < " + logFileSizeK + "K");
   111         }
   112     }
   114     public static void main(String[] args) throws Exception {
   115         cleanLogs();
   116         runTest(1);
   117         cleanLogs();
   118         runTest(3);
   119         cleanLogs();
   120     }
   121 }

mercurial