< prev index next >

test/hotspot/jtreg/runtime/SharedArchiveFile/MaxMetaspaceSize.java

Print this page




  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  */
  23 
  24 /**
  25  * @test
  26  * @requires vm.cds
  27  * @bug 8067187
  28  * @summary Testing CDS dumping with the -XX:MaxMetaspaceSize=<size> option
  29  * @library /test/lib
  30  * @modules java.base/jdk.internal.misc
  31  *          java.management
  32  */
  33 


  34 import jdk.test.lib.cds.CDSTestUtils;
  35 import jdk.test.lib.process.ProcessTools;
  36 
  37 public class MaxMetaspaceSize {
  38   public static void main(String[] args) throws Exception {









  39     String msg = "OutOfMemoryError: Metaspace";
  40     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  41         "-XX:MaxMetaspaceSize=1m", "-Xshare:dump");
  42     CDSTestUtils.executeAndLog(pb, "dump").shouldContain(msg).shouldHaveExitValue(1);
  43   }
  44 }


  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  */
  23 
  24 /**
  25  * @test
  26  * @requires vm.cds
  27  * @bug 8067187
  28  * @summary Testing CDS dumping with the -XX:MaxMetaspaceSize=<size> option
  29  * @library /test/lib
  30  * @modules java.base/jdk.internal.misc
  31  *          java.management
  32  */
  33 
  34 import java.util.ArrayList;
  35 
  36 import jdk.test.lib.cds.CDSTestUtils;
  37 import jdk.test.lib.process.ProcessTools;
  38 
  39 public class MaxMetaspaceSize {
  40   public static void main(String[] args) throws Exception {
  41     ArrayList<String> processArgs = new ArrayList<>();
  42     processArgs.add("-Xshare:dump");
  43     processArgs.add("-XX:MaxMetaspaceSize=3m");
  44 
  45     if (System.getProperty("os.arch").contains("64")) {
  46       processArgs.add("-XX:CompressedClassSpaceSize=1m");
  47       processArgs.add("-XX:InitialBootClassLoaderMetaspaceSize=1m");
  48     }
  49 
  50     String msg = "OutOfMemoryError: Metaspace";
  51     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(processArgs.toArray(new String[0]));

  52     CDSTestUtils.executeAndLog(pb, "dump").shouldContain(msg).shouldHaveExitValue(1);
  53   }
  54 }
< prev index next >