Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/ClassFile/JsrRewriting.java
32283 views
/*1* Copyright (c) 2011, 2013, 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 JsrRewriting27* @summary JSR (jump local subroutine)28* rewriting can overflow memory address size variables29* @bug 702037330* @bug 705524731* @bug 705358632* @bug 718555033* @bug 714946434* @key cte_test35* @library /testlibrary36* @run main JsrRewriting37*/3839import com.oracle.java.testlibrary.*;40import java.io.File;4142public class JsrRewriting {4344public static void main(String[] args) throws Exception {4546// ======= Configure the test47String jarFile = System.getProperty("test.src") +48File.separator + "JsrRewritingTestCase.jar";49String className = "OOMCrashClass4000_1";5051// limit is 768MB in native words52int mallocMaxTestWords = (1024 * 1024 * 768 / 4);53if (Platform.is64bit())54mallocMaxTestWords = (mallocMaxTestWords / 2);5556// ======= extract the test class57ProcessBuilder pb = new ProcessBuilder(new String[] {58JDKToolFinder.getJDKTool("jar"),59"xvf", jarFile } );60OutputAnalyzer output = new OutputAnalyzer(pb.start());61output.shouldHaveExitValue(0);6263// ======= execute the test64pb = ProcessTools.createJavaProcessBuilder(65"-cp", ".",66"-XX:+UnlockDiagnosticVMOptions",67"-XX:MallocMaxTestWords=" + mallocMaxTestWords,68className);6970output = new OutputAnalyzer(pb.start());71String[] expectedMsgs = {72"java.lang.LinkageError",73"java.lang.NoSuchMethodError",74"Main method not found in class " + className,75"insufficient memory"76};7778MultipleOrMatch(output, expectedMsgs);79}8081private static void82MultipleOrMatch(OutputAnalyzer analyzer, String[] whatToMatch) {83String output = analyzer.getOutput();8485for (String expected : whatToMatch)86if (output.contains(expected))87return;8889String err =90" stdout: [" + analyzer.getOutput() + "];\n" +91" exitValue = " + analyzer.getExitValue() + "\n";92System.err.println(err);9394StringBuilder msg = new StringBuilder("Output did not contain " +95"any of the following expected messages: \n");96for (String expected : whatToMatch)97msg.append(expected).append(System.lineSeparator());98throw new RuntimeException(msg.toString());99}100}101102103104