Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java
32284 views
/*1* Copyright (c) 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*/2223/*24* @test25* @bug 7051189 802339326* @summary Need to suppress info message if -Xcheck:jni is used with libjsig.so27* @library /testlibrary28* @run main XCheckJSig29*/3031import java.util.*;32import com.oracle.java.testlibrary.*;3334public class XCheckJSig {35public static void main(String args[]) throws Throwable {3637System.out.println("Regression test for bugs 7051189 and 8023393");38if (!Platform.isSolaris() && !Platform.isLinux() && !Platform.isOSX()) {39System.out.println("Test only applicable on Solaris, Linux, and Mac OSX, skipping");40return;41}4243String jdk_path = System.getProperty("test.jdk");44String os_arch = Platform.getOsArch();45String libjsig;46String env_var;47if (Platform.isOSX()) {48libjsig = jdk_path + "/jre/lib/server/libjsig.dylib";49env_var = "DYLD_INSERT_LIBRARIES";50} else {51libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so";52env_var = "LD_PRELOAD";53}54String java_program;55if (Platform.isSolaris()) {56// On Solaris, need to call the 64-bit Java directly in order for57// LD_PRELOAD to work because libjsig.so is 64-bit.58java_program = jdk_path + "/jre/bin/" + os_arch + "/java";59} else {60java_program = JDKToolFinder.getJDKTool("java");61}62// If this test fails, these might be useful to know.63System.out.println("libjsig: " + libjsig);64System.out.println("osArch: " + os_arch);65System.out.println("java_program: " + java_program);6667ProcessBuilder pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-version");68Map<String, String> env = pb.environment();69env.put(env_var, libjsig);70OutputAnalyzer output = new OutputAnalyzer(pb.start());71output.shouldNotContain("libjsig is activated");72output.shouldHaveExitValue(0);7374pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-verbose:jni", "-version");75env = pb.environment();76env.put(env_var, libjsig);77output = new OutputAnalyzer(pb.start());78output.shouldContain("libjsig is activated");79output.shouldHaveExitValue(0);80}81}828384