# HG changeset patch # User dcubed # Date 1377279555 25200 # Node ID cacc421f39d764833c26ad0e21660bc92cf39a84 # Parent 73921c720b943ee44be1e883c8383baf512a5c20# Parent 739c309fd72992e55ccd6a2ddcd2b57f3b000ca0 Merge diff -r 73921c720b94 -r cacc421f39d7 agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js Fri Aug 23 03:14:54 2013 -0700 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js Fri Aug 23 10:39:15 2013 -0700 @@ -35,8 +35,9 @@ sapkg.code = sapkg.hotspot.code; sapkg.compiler = sapkg.hotspot.compiler; -// 'debugger' is a JavaScript keyword :-( -// sapkg.debugger = sapkg.hotspot.debugger; +// 'debugger' is a JavaScript keyword, but ES5 relaxes the +// restriction of using keywords as property name +sapkg.debugger = sapkg.hotspot.debugger; sapkg.interpreter = sapkg.hotspot.interpreter; sapkg.jdi = sapkg.hotspot.jdi; @@ -116,27 +117,36 @@ return args; } + // Handle __has__ specially to avoid metacircularity problems + // when called from __get__. + // Calling + // this.__has__(name) + // will in turn call + // this.__call__('__has__', name) + // which is not handled below + function __has__(name) { + if (typeof(name) == 'number') { + return so["has(int)"](name); + } else { + if (name == '__wrapped__') { + return true; + } else if (so["has(java.lang.String)"](name)) { + return true; + } else if (name.equals('toString')) { + return true; + } else { + return false; + } + } + } + if (so instanceof sapkg.utilities.soql.ScriptObject) { return new JSAdapter() { - __getIds__: function() { - return so.getIds(); + __getIds__: function() { + return so.getIds(); }, - __has__ : function(name) { - if (typeof(name) == 'number') { - return so["has(int)"](name); - } else { - if (name == '__wrapped__') { - return true; - } else if (so["has(java.lang.String)"](name)) { - return true; - } else if (name.equals('toString')) { - return true; - } else { - return false; - } - } - }, + __has__ : __has__, __delete__ : function(name) { if (typeof(name) == 'number') { @@ -147,7 +157,8 @@ }, __get__ : function(name) { - if (! this.__has__(name)) { + // don't call this.__has__(name); see comments above function __has__ + if (! __has__.call(this, name)) { return undefined; } if (typeof(name) == 'number') { @@ -162,7 +173,7 @@ var args = prepareArgsArray(arguments); var r; try { - r = value.call(args); + r = value.call(Java.to(args, 'java.lang.Object[]')); } catch (e) { println("call to " + name + " failed!"); throw e; @@ -204,6 +215,18 @@ } // define "writeln" and "write" if not defined + if (typeof(println) == 'undefined') { + println = function (str) { + java.lang.System.out.println(String(str)); + } + } + + if (typeof(print) == 'undefined') { + print = function (str) { + java.lang.System.out.print(String(str)); + } + } + if (typeof(writeln) == 'undefined') { writeln = println; } @@ -235,7 +258,7 @@ this.jclasses = function() { forEachKlass(function (clazz) { - writeln(clazz.getName().asString() + " @" + clazz.getHandle().toString()); + writeln(clazz.getName().asString() + " @" + clazz.getAddress().toString()); }); } registerCommand("classes", "classes", "jclasses"); @@ -490,14 +513,14 @@ function forEachKlass(callback) { var VisitorClass = sapkg.memory.SystemDictionary.ClassVisitor; var visitor = new VisitorClass() { visit: callback }; - sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary$ClassVisitor)"](visitor); + sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary.ClassVisitor)"](visitor); } // iterate system dictionary for each 'Klass' and initiating loader function forEachKlassAndLoader(callback) { var VisitorClass = sapkg.memory.SystemDictionary.ClassAndLoaderVisitor; var visitor = new VisitorClass() { visit: callback }; - sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary$ClassAndLoaderVisitor)"](visitor); + sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary.ClassAndLoaderVisitor)"](visitor); } // iterate system dictionary for each primitive array klass @@ -522,7 +545,12 @@ // iterates Java heap for each Oop function forEachOop(callback) { - sa.objHeap.iterate(new sapkg.oops.HeapVisitor() { doObj: callback }); + function empty() { } + sa.objHeap.iterate(new sapkg.oops.HeapVisitor() { + prologue: empty, + doObj: callback, + epilogue: empty + }); } // iterates Java heap for each Oop of given 'klass'. @@ -536,8 +564,14 @@ if (includeSubtypes == undefined) { includeSubtypes = true; } + + function empty() { } sa.objHeap.iterateObjectsOfKlass( - new sapkg.oops.HeapVisitor() { doObj: callback }, + new sapkg.oops.HeapVisitor() { + prologue: empty, + doObj: callback, + epilogue: empty + }, klass, includeSubtypes); } @@ -746,9 +780,9 @@ // ignore; continue; } else { - // some type names have ':'. replace to make it as a + // some type names have ':', '<', '>', '*', ' '. replace to make it as a // JavaScript identifier - tmp.name = tmp.name.replace(':', '_').replace('<', '_').replace('>', '_').replace('*', '_').replace(' ', '_'); + tmp.name = ("" + tmp.name).replace(/[:<>* ]/g, '_'); eval("function read" + tmp.name + "(addr) {" + " return readVMType('" + tmp.name + "', addr);}"); eval("function print" + tmp.name + "(addr) {" + diff -r 73921c720b94 -r cacc421f39d7 make/windows/build_vm_def.sh --- a/make/windows/build_vm_def.sh Fri Aug 23 03:14:54 2013 -0700 +++ b/make/windows/build_vm_def.sh Fri Aug 23 10:39:15 2013 -0700 @@ -42,8 +42,6 @@ MKS_HOME=`dirname "$SH"` fi -echo "EXPORTS" > vm1.def - AWK="$MKS_HOME/awk.exe" if [ ! -e $AWK ]; then AWK="$MKS_HOME/gawk.exe" @@ -55,6 +53,22 @@ RM="$MKS_HOME/rm.exe" DUMPBIN="link.exe /dump" +if [ "$1" = "-nosa" ]; then + echo EXPORTS > vm.def + echo "" + echo "***" + echo "*** Not building SA: BUILD_WIN_SA != 1" + echo "*** C++ Vtables NOT included in vm.def" + echo "*** This jvm.dll will NOT work properly with SA." + echo "***" + echo "*** When in doubt, set BUILD_WIN_SA=1, clean and rebuild." + echo "***" + echo "" + exit +fi + +echo "EXPORTS" > vm1.def + # When called from IDE the first param should contain the link version, otherwise may be nill if [ "x$1" != "x" ]; then LD_VER="$1" diff -r 73921c720b94 -r cacc421f39d7 make/windows/makefiles/debug.make --- a/make/windows/makefiles/debug.make Fri Aug 23 03:14:54 2013 -0700 +++ b/make/windows/makefiles/debug.make Fri Aug 23 10:39:15 2013 -0700 @@ -49,9 +49,6 @@ # Force resources to be rebuilt every time $(Res_Files): FORCE -vm.def: $(Obj_Files) - sh $(WorkSpace)/make/windows/build_vm_def.sh - $(AOUT): $(Res_Files) $(Obj_Files) vm.def $(LD) @<< $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) diff -r 73921c720b94 -r cacc421f39d7 make/windows/makefiles/fastdebug.make --- a/make/windows/makefiles/fastdebug.make Fri Aug 23 03:14:54 2013 -0700 +++ b/make/windows/makefiles/fastdebug.make Fri Aug 23 10:39:15 2013 -0700 @@ -48,9 +48,6 @@ # Force resources to be rebuilt every time $(Res_Files): FORCE -vm.def: $(Obj_Files) - sh $(WorkSpace)/make/windows/build_vm_def.sh - $(AOUT): $(Res_Files) $(Obj_Files) vm.def $(LD) @<< $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) diff -r 73921c720b94 -r cacc421f39d7 make/windows/makefiles/product.make --- a/make/windows/makefiles/product.make Fri Aug 23 03:14:54 2013 -0700 +++ b/make/windows/makefiles/product.make Fri Aug 23 10:39:15 2013 -0700 @@ -51,9 +51,6 @@ # Force resources to be rebuilt every time $(Res_Files): FORCE -vm.def: $(Obj_Files) - sh $(WorkSpace)/make/windows/build_vm_def.sh - $(AOUT): $(Res_Files) $(Obj_Files) vm.def $(LD) @<< $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) diff -r 73921c720b94 -r cacc421f39d7 make/windows/makefiles/projectcreator.make --- a/make/windows/makefiles/projectcreator.make Fri Aug 23 03:14:54 2013 -0700 +++ b/make/windows/makefiles/projectcreator.make Fri Aug 23 10:39:15 2013 -0700 @@ -92,6 +92,10 @@ -disablePch getThread_windows_$(Platform_arch).cpp \ -disablePch_compiler2 opcodes.cpp +!if "$(BUILD_WIN_SA)" != "1" +BUILD_VM_DEF_FLAG=-nosa +!endif + # Common options for the IDE builds for c1, and c2 ProjectCreatorIDEOptions=\ $(ProjectCreatorIDEOptions) \ @@ -104,7 +108,7 @@ -jdkTargetRoot $(HOTSPOTJDKDIST) \ -define ALIGN_STACK_FRAMES \ -define VM_LITTLE_ENDIAN \ - -prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) set JAVA_HOME=$(HOTSPOTJDKDIST) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LD_VER)" \ + -prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) set JAVA_HOME=$(HOTSPOTJDKDIST) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(BUILD_VM_DEF_FLAG) $(LD_VER)" \ -ignoreFile jsig.c \ -ignoreFile jvmtiEnvRecommended.cpp \ -ignoreFile jvmtiEnvStub.cpp \ diff -r 73921c720b94 -r cacc421f39d7 make/windows/makefiles/vm.make --- a/make/windows/makefiles/vm.make Fri Aug 23 03:14:54 2013 -0700 +++ b/make/windows/makefiles/vm.make Fri Aug 23 10:39:15 2013 -0700 @@ -393,3 +393,11 @@ _build_pch_file.obj: @echo #include "precompiled.hpp" > ../generated/_build_pch_file.cpp $(CXX) $(CXX_FLAGS) /Fp"vm.pch" /Yc"precompiled.hpp" /c ../generated/_build_pch_file.cpp + +!if "$(BUILD_WIN_SA)" != "1" +BUILD_VM_DEF_FLAG=-nosa +!endif + +vm.def: $(Obj_Files) + sh $(WorkSpace)/make/windows/build_vm_def.sh $(BUILD_VM_DEF_FLAG) + diff -r 73921c720b94 -r cacc421f39d7 src/os/bsd/vm/os_bsd.cpp --- a/src/os/bsd/vm/os_bsd.cpp Fri Aug 23 03:14:54 2013 -0700 +++ b/src/os/bsd/vm/os_bsd.cpp Fri Aug 23 10:39:15 2013 -0700 @@ -642,13 +642,14 @@ #endif #ifdef __APPLE__ -static uint64_t locate_unique_thread_id() { +static uint64_t locate_unique_thread_id(mach_port_t mach_thread_port) { // Additional thread_id used to correlate threads in SA thread_identifier_info_data_t m_ident_info; mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT; - thread_info(::mach_thread_self(), THREAD_IDENTIFIER_INFO, + thread_info(mach_thread_port, THREAD_IDENTIFIER_INFO, (thread_info_t) &m_ident_info, &count); + return m_ident_info.thread_id; } #endif @@ -679,9 +680,14 @@ } #ifdef __APPLE__ - // thread_id is mach thread on macos - osthread->set_thread_id(::mach_thread_self()); - osthread->set_unique_thread_id(locate_unique_thread_id()); + // thread_id is mach thread on macos, which pthreads graciously caches and provides for us + mach_port_t thread_id = ::pthread_mach_thread_np(::pthread_self()); + guarantee(thread_id != 0, "thread id missing from pthreads"); + osthread->set_thread_id(thread_id); + + uint64_t unique_thread_id = locate_unique_thread_id(thread_id); + guarantee(unique_thread_id != 0, "unique thread id was not found"); + osthread->set_unique_thread_id(unique_thread_id); #else // thread_id is pthread_id on BSD osthread->set_thread_id(::pthread_self()); @@ -843,8 +849,14 @@ // Store pthread info into the OSThread #ifdef __APPLE__ - osthread->set_thread_id(::mach_thread_self()); - osthread->set_unique_thread_id(locate_unique_thread_id()); + // thread_id is mach thread on macos, which pthreads graciously caches and provides for us + mach_port_t thread_id = ::pthread_mach_thread_np(::pthread_self()); + guarantee(thread_id != 0, "just checking"); + osthread->set_thread_id(thread_id); + + uint64_t unique_thread_id = locate_unique_thread_id(thread_id); + guarantee(unique_thread_id != 0, "just checking"); + osthread->set_unique_thread_id(unique_thread_id); #else osthread->set_thread_id(::pthread_self()); #endif @@ -1115,7 +1127,7 @@ intx os::current_thread_id() { #ifdef __APPLE__ - return (intx)::mach_thread_self(); + return (intx)::pthread_mach_thread_np(::pthread_self()); #else return (intx)::pthread_self(); #endif @@ -3275,11 +3287,15 @@ // and if UserSignalHandler is installed all bets are off if (CheckJNICalls) { if (libjsig_is_loaded) { - tty->print_cr("Info: libjsig is activated, all active signal checking is disabled"); + if (PrintJNIResolving) { + tty->print_cr("Info: libjsig is activated, all active signal checking is disabled"); + } check_signals = false; } if (AllowUserSignalHandlers) { - tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); + if (PrintJNIResolving) { + tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); + } check_signals = false; } } diff -r 73921c720b94 -r cacc421f39d7 src/share/vm/prims/jvmtiRedefineClasses.cpp --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp Fri Aug 23 03:14:54 2013 -0700 +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp Fri Aug 23 10:39:15 2013 -0700 @@ -1554,18 +1554,22 @@ return false; } - // rewrite sourc file name index: + // rewrite source file name index: u2 source_file_name_idx = scratch_class->source_file_name_index(); if (source_file_name_idx != 0) { u2 new_source_file_name_idx = find_new_index(source_file_name_idx); - scratch_class->set_source_file_name_index(new_source_file_name_idx); + if (new_source_file_name_idx != 0) { + scratch_class->set_source_file_name_index(new_source_file_name_idx); + } } // rewrite class generic signature index: u2 generic_signature_index = scratch_class->generic_signature_index(); if (generic_signature_index != 0) { u2 new_generic_signature_index = find_new_index(generic_signature_index); - scratch_class->set_generic_signature_index(new_generic_signature_index); + if (new_generic_signature_index != 0) { + scratch_class->set_generic_signature_index(new_generic_signature_index); + } } return true; @@ -1737,7 +1741,10 @@ for (int i = 0; i < len; i++) { const u2 cp_index = elem[i].name_cp_index; - elem[i].name_cp_index = find_new_index(cp_index); + const u2 new_cp_index = find_new_index(cp_index); + if (new_cp_index != 0) { + elem[i].name_cp_index = new_cp_index; + } } } } // end rewrite_cp_refs_in_method() diff -r 73921c720b94 -r cacc421f39d7 src/share/vm/runtime/mutexLocker.cpp --- a/src/share/vm/runtime/mutexLocker.cpp Fri Aug 23 03:14:54 2013 -0700 +++ b/src/share/vm/runtime/mutexLocker.cpp Fri Aug 23 10:39:15 2013 -0700 @@ -124,13 +124,15 @@ Mutex* Management_lock = NULL; Monitor* Service_lock = NULL; -Mutex* Stacktrace_lock = NULL; +Monitor* PeriodicTask_lock = NULL; -Monitor* JfrQuery_lock = NULL; +#ifdef INCLUDE_TRACE +Mutex* JfrStacktrace_lock = NULL; Monitor* JfrMsg_lock = NULL; Mutex* JfrBuffer_lock = NULL; Mutex* JfrStream_lock = NULL; -Monitor* PeriodicTask_lock = NULL; +Mutex* JfrThreadGroups_lock = NULL; +#endif #define MAX_NUM_MUTEX 128 static Monitor * _mutex_array[MAX_NUM_MUTEX]; @@ -206,7 +208,6 @@ def(Patching_lock , Mutex , special, true ); // used for safepointing and code patching. def(ObjAllocPost_lock , Monitor, special, false); def(Service_lock , Monitor, special, true ); // used for service thread operations - def(Stacktrace_lock , Mutex, special, true ); // used for JFR stacktrace database def(JmethodIdCreation_lock , Mutex , leaf, true ); // used for creating jmethodIDs. def(SystemDictionary_lock , Monitor, leaf, true ); // lookups done by VM thread @@ -272,11 +273,16 @@ def(Debug3_lock , Mutex , nonleaf+4, true ); def(ProfileVM_lock , Monitor, special, false); // used for profiling of the VMThread def(CompileThread_lock , Monitor, nonleaf+5, false ); + def(PeriodicTask_lock , Monitor, nonleaf+5, true); +#ifdef INCLUDE_TRACE def(JfrMsg_lock , Monitor, leaf, true); def(JfrBuffer_lock , Mutex, nonleaf+1, true); + def(JfrThreadGroups_lock , Mutex, nonleaf+1, true); def(JfrStream_lock , Mutex, nonleaf+2, true); - def(PeriodicTask_lock , Monitor, nonleaf+5, true); + def(JfrStacktrace_lock , Mutex, special, true ); +#endif + } GCMutexLocker::GCMutexLocker(Monitor * mutex) { diff -r 73921c720b94 -r cacc421f39d7 src/share/vm/runtime/mutexLocker.hpp --- a/src/share/vm/runtime/mutexLocker.hpp Fri Aug 23 03:14:54 2013 -0700 +++ b/src/share/vm/runtime/mutexLocker.hpp Fri Aug 23 10:39:15 2013 -0700 @@ -137,13 +137,15 @@ extern Mutex* Management_lock; // a lock used to serialize JVM management extern Monitor* Service_lock; // a lock used for service thread operation -extern Mutex* Stacktrace_lock; // used to guard access to the stacktrace table +extern Monitor* PeriodicTask_lock; // protects the periodic task structure -extern Monitor* JfrQuery_lock; // protects JFR use +#ifdef INCLUDE_TRACE +extern Mutex* JfrStacktrace_lock; // used to guard access to the JFR stacktrace table extern Monitor* JfrMsg_lock; // protects JFR messaging extern Mutex* JfrBuffer_lock; // protects JFR buffer operations extern Mutex* JfrStream_lock; // protects JFR stream access -extern Monitor* PeriodicTask_lock; // protects the periodic task structure +extern Mutex* JfrThreadGroups_lock; // protects JFR access to Thread Groups +#endif // A MutexLocker provides mutual exclusion with respect to a given mutex // for the scope which contains the locker. The lock is an OS lock, not diff -r 73921c720b94 -r cacc421f39d7 src/share/vm/services/management.cpp --- a/src/share/vm/services/management.cpp Fri Aug 23 03:14:54 2013 -0700 +++ b/src/share/vm/services/management.cpp Fri Aug 23 10:39:15 2013 -0700 @@ -876,8 +876,6 @@ total_used += u.used(); total_committed += u.committed(); - // if any one of the memory pool has undefined init_size or max_size, - // set it to -1 if (u.init_size() == (size_t)-1) { has_undefined_init_size = true; } @@ -894,6 +892,15 @@ } } + // if any one of the memory pool has undefined init_size or max_size, + // set it to -1 + if (has_undefined_init_size) { + total_init = (size_t)-1; + } + if (has_undefined_max_size) { + total_max = (size_t)-1; + } + MemoryUsage usage((heap ? InitialHeapSize : total_init), total_used, total_committed, diff -r 73921c720b94 -r cacc421f39d7 test/runtime/7051189/Xchecksig.sh --- a/test/runtime/7051189/Xchecksig.sh Fri Aug 23 03:14:54 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - - -# @test Xchecksig.sh -# @bug 7051189 -# @summary Need to suppress info message if -xcheck:jni used with libjsig.so -# @run shell Xchecksig.sh -# - -if [ "${TESTSRC}" = "" ] -then - TESTSRC=${PWD} - echo "TESTSRC not set. Using "${TESTSRC}" as default" -fi -echo "TESTSRC=${TESTSRC}" -## Adding common setup Variables for running shell tests. -. ${TESTSRC}/../../test_env.sh - -OS=`uname -s` -case "$OS" in - Windows_* | CYGWIN_* ) - printf "Not testing libjsig.so on Windows. PASSED.\n " - exit 0 - ;; -esac - -JAVA=${TESTJAVA}${FS}bin${FS}java - -# LD_PRELOAD arch needs to match the binary we run, so run the java -# 64-bit binary directly if we are testing 64-bit (bin/ARCH/java). -# Check if TESTVMOPS contains -d64, but cannot use -# java ${TESTVMOPS} to run "java -d64" with LD_PRELOAD. - -if [ ${OS} -eq "SunOS" ] -then - printf "SunOS test TESTVMOPTS = ${TESTVMOPTS}" - printf ${TESTVMOPTS} | grep d64 > /dev/null - if [ $? -eq 0 ] - then - printf "SunOS 64-bit test\n" - BIT_FLAG=-d64 - fi -fi - -ARCH=`uname -p` -case $ARCH in - i386) - if [ X${BIT_FLAG} != "X" ] - then - ARCH=amd64 - JAVA=${TESTJAVA}${FS}bin${FS}${ARCH}${FS}java - fi - ;; - sparc) - if [ X${BIT_FLAG} != "X" ] - then - ARCH=sparcv9 - JAVA=${TESTJAVA}${FS}bin${FS}${ARCH}${FS}java - fi - ;; - * ) - printf "Not testing architecture $ARCH, skipping test.\n" - exit 0 - ;; -esac - -LIBJSIG=${COMPILEJAVA}${FS}jre${FS}lib${FS}${ARCH}${FS}libjsig.so - -# If libjsig and binary do not match, skip test. - -A=`file ${LIBJSIG} | awk '{ print $3 }'` -B=`file ${JAVA} | awk '{ print $3 }'` - -if [ $A -ne $B ] -then - printf "Mismatching binary and library to preload, skipping test.\n" - exit 0 -fi - -if [ ! -f ${LIBJSIG} ] -then - printf "Skipping test: libjsig missing for given architecture: ${LIBJSIG}\n" - exit 0 -fi -# Use java -version to test, java version info appears on stderr, -# the libjsig message we are removing appears on stdout. - -# grep returns zero meaning found, non-zero means not found: - -LD_PRELOAD=${LIBJSIG} ${JAVA} ${TESTVMOPTS} -Xcheck:jni -version 2>&1 | grep "libjsig is activated" -if [ $? -eq 0 ]; then - printf "Failed: -Xcheck:jni prints message when libjsig.so is loaded.\n" - exit 1 -fi - - -LD_PRELOAD=${LIBJSIG} ${JAVA} ${TESTVMOPTS} -Xcheck:jni -verbose:jni -version 2>&1 | grep "libjsig is activated" -if [ $? != 0 ]; then - printf "Failed: -Xcheck:jni does not print message when libjsig.so is loaded and -verbose:jni is set.\n" - exit 1 -fi - -printf "PASSED\n" -exit 0 - diff -r 73921c720b94 -r cacc421f39d7 test/runtime/XCheckJniJsig/XCheckJSig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/XCheckJniJsig/XCheckJSig.java Fri Aug 23 10:39:15 2013 -0700 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7051189 8023393 + * @summary Need to suppress info message if -Xcheck:jni is used with libjsig.so + * @library /testlibrary + * @run main XCheckJSig + */ + +import java.util.*; +import com.oracle.java.testlibrary.*; + +public class XCheckJSig { + public static void main(String args[]) throws Throwable { + + System.out.println("Regression test for bugs 7051189 and 8023393"); + if (!Platform.isSolaris() && !Platform.isLinux() && !Platform.isOSX()) { + System.out.println("Test only applicable on Solaris, Linux, and Mac OSX, skipping"); + return; + } + + String jdk_path = System.getProperty("test.jdk"); + String os_arch = Platform.getOsArch(); + String libjsig; + String env_var; + if (Platform.isOSX()) { + libjsig = jdk_path + "/jre/lib/server/libjsig.dylib"; + env_var = "DYLD_INSERT_LIBRARIES"; + } else { + libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so"; + env_var = "LD_PRELOAD"; + } + String java_program; + if (Platform.isSolaris()) { + // On Solaris, need to call the 64-bit Java directly in order for + // LD_PRELOAD to work because libjsig.so is 64-bit. + java_program = jdk_path + "/jre/bin/" + os_arch + "/java"; + } else { + java_program = JDKToolFinder.getJDKTool("java"); + } + // If this test fails, these might be useful to know. + System.out.println("libjsig: " + libjsig); + System.out.println("osArch: " + os_arch); + System.out.println("java_program: " + java_program); + + ProcessBuilder pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-version"); + Map env = pb.environment(); + env.put(env_var, libjsig); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("libjsig is activated"); + output.shouldHaveExitValue(0); + + pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-verbose:jni", "-version"); + env = pb.environment(); + env.put(env_var, libjsig); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("libjsig is activated"); + output.shouldHaveExitValue(0); + } +}