Path: blob/master/test/hotspot/jtreg/runtime/ClassFile/OomWhileParsingRepeatedJsr.java
40941 views
/*1* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22232425/*26* @test OomWhileParsingRepeatedJsr27* @summary Testing class file parser; specifically parsing28* a file with repeated JSR (jump local subroutine)29* bytecode command.30* @bug 687871331* @bug 703061032* @bug 703712233* @bug 712394534* @bug 801602935* @library /test/lib36* @modules java.base/jdk.internal.misc37* java.desktop38* java.management39* @run driver OomWhileParsingRepeatedJsr40*/4142import jdk.test.lib.JDKToolFinder;43import jdk.test.lib.Platform;44import jdk.test.lib.process.ProcessTools;45import jdk.test.lib.process.OutputAnalyzer;4647public class OomWhileParsingRepeatedJsr {4849public static void main(String[] args) throws Exception {5051// ======= Configure the test52String jarFile = System.getProperty("test.src") + "/testcase.jar";53String className = "OOMCrashClass1960_2";5455// limit is 768MB in native words56int mallocMaxTestWords = (1024 * 1024 * 768 / 4);57if (Platform.is64bit())58mallocMaxTestWords = (mallocMaxTestWords / 2);5960// ======= extract the test class61ProcessBuilder pb = new ProcessBuilder(new String[] {62JDKToolFinder.getJDKTool("jar"),63"xvf", jarFile } );64OutputAnalyzer output = new OutputAnalyzer(pb.start());65output.shouldHaveExitValue(0);6667// ======= execute the test68pb = ProcessTools.createJavaProcessBuilder(69"-cp", ".",70"-XX:+UnlockDiagnosticVMOptions",71"-XX:MallocMaxTestWords=" + mallocMaxTestWords,72className );7374output = new OutputAnalyzer(pb.start());75output.shouldContain("Cannot reserve enough memory");76}77}78798081