hotspot/test/runtime/SharedArchiveFile/MaxMetaspaceSize.java
author ccheung
Mon, 12 Jan 2015 11:37:58 -0800
changeset 28476 ae1ca3bf45ca
child 29678 dd2f3932c21e
permissions -rw-r--r--
8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash Summary: added check for the MaxMetaspaceSize. If it is less than the estimated required size, print an error and exit. Reviewed-by: jiangli, mseledtsov, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28476
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     1
/*
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     4
 *
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     8
 *
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    13
 * accompanied this code).
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    14
 *
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    18
 *
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    21
 * questions.
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    22
 */
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    23
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    24
/*
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    25
 * @test
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    26
 * @bug 8067187
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    27
 * @summary Testing CDS dumping with the -XX:MaxMetaspaceSize=<size> option
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    28
 * @library /testlibrary
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    29
 */
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    30
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    31
import com.oracle.java.testlibrary.*;
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    32
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    33
public class MaxMetaspaceSize {
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    34
  public static void main(String[] args) throws Exception {
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    35
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    36
        "-XX:MaxMetaspaceSize=20m", "-Xshare:dump");
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    37
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    38
      output.shouldContain("is not large enough.\nEither don't specify the -XX:MaxMetaspaceSize=<size>\nor increase the size to at least");
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    39
      output.shouldHaveExitValue(2);
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    40
  }
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    41
}