This commit is contained in:
Daniel D. Daugherty 2016-04-14 15:25:41 -07:00
commit 451af9b1b2
23 changed files with 544 additions and 581 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, 2016, 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
@ -83,20 +83,20 @@ ifneq ($(STATIC_BUILD), true)
endif
ifneq ($(OPENJDK_TARGET_OS), windows)
ifeq ($(JVM_VARIANT_SERVER), true)
ifeq ($(call check-jvm-variant, server), true)
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/server/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX)
ifneq (, $(JSIG_DEBUGINFO))
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/server/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))
endif
endif
ifeq ($(JVM_VARIANT_CLIENT), true)
ifeq ($(call check-jvm-variant, client), true)
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/client/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX)
ifneq (, $(JSIG_DEBUGINFO))
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/client/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))
endif
endif
ifneq ($(OPENJDK_TARGET_OS), macosx)
ifeq ($(JVM_VARIANT_MINIMAL1), true)
ifeq ($(call check-jvm-variant, minimal), true)
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/minimal/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX)
ifneq (,$(JSIG_DEBUGINFO))
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/minimal/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2014, 2016, 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
@ -88,7 +88,7 @@ endif
#
# How to install jvm.cfg.
#
ifeq ($(JVM_VARIANT_ZERO), true)
ifeq ($(call check-jvm-variant, zero zeroshark), true)
JVMCFG_ARCH := zero
else
JVMCFG_ARCH := $(OPENJDK_TARGET_CPU_LEGACY)
@ -99,7 +99,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx)
else
JVMCFG_SRC := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/$(JVMCFG_ARCH)/jvm.cfg
# Allow override by ALT_JVMCFG_SRC if it exists
JVMCFG_SRC := $(if $(wildcard $(ALT_JVMCFG_SRC)),$(ALT_JVMCFG_SRC),$(JVMCFG_SRC))
JVMCFG_SRC := $(if $(wildcard $(ALT_JVMCFG_SRC)),$(ALT_JVMCFG_SRC),$(JVMCFG_SRC))
endif
JVMCFG_DIR := $(LIB_DST_DIR)$(OPENJDK_TARGET_CPU_LIBDIR)
JVMCFG := $(JVMCFG_DIR)/jvm.cfg
@ -117,12 +117,12 @@ else
# The main problem is deciding whether to use aliases for the VMs that are not
# present and the current position is that we add aliases for client and server, but
# not for minimal.
CLIENT_AND_SERVER := $(and $(findstring true, $(JVM_VARIANT_SERVER)), $(findstring true, $(JVM_VARIANT_CLIENT)))
ifeq ($(CLIENT_AND_SERVER), true)
CLIENT_AND_SERVER := $(call check-jvm-variant, client)+$(call check-jvm-variant, server)
ifeq ($(CLIENT_AND_SERVER), true+true)
COPY_JVM_CFG_FILE := true
else
# For zero, the default jvm.cfg file is sufficient
ifeq ($(JVM_VARIANT_ZERO), true)
ifeq ($(call check-jvm-variant, zero zeroshark), true)
COPY_JVM_CFG_FILE := true
endif
endif
@ -136,21 +136,21 @@ else
$(MKDIR) -p $(@D)
$(RM) $(@)
# Now check for other permutations
ifeq ($(JVM_VARIANT_SERVER), true)
ifeq ($(call check-jvm-variant, server), true)
$(PRINTF) "-server KNOWN\n">>$(@)
$(PRINTF) "-client ALIASED_TO -server\n">>$(@)
ifeq ($(JVM_VARIANT_MINIMAL1), true)
ifeq ($(call check-jvm-variant, minimal), true)
$(PRINTF) "-minimal KNOWN\n">>$(@)
endif
else
ifeq ($(JVM_VARIANT_CLIENT), true)
ifeq ($(call check-jvm-variant, client), true)
$(PRINTF) "-client KNOWN\n">>$(@)
$(PRINTF) "-server ALIASED_TO -client\n">>$(@)
ifeq ($(JVM_VARIANT_MINIMAL1), true)
ifeq ($(call check-jvm-variant, minimal), true)
$(PRINTF) "-minimal KNOWN\n">>$(@)
endif
else
ifeq ($(JVM_VARIANT_MINIMAL1), true)
ifeq ($(call check-jvm-variant, minimal), true)
$(PRINTF) "-minimal KNOWN\n">>$(@)
$(PRINTF) "-server ALIASED_TO -minimal\n">>$(@)
$(PRINTF) "-client ALIASED_TO -minimal\n">>$(@)

View File

@ -375,6 +375,7 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),)
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_XAWT_CFLAGS) \
$(X_CFLAGS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := type-limits pointer-to-int-cast \
deprecated-declarations unused-result maybe-uninitialized format \
format-security int-to-pointer-cast parentheses, \
@ -587,6 +588,7 @@ ifeq ($(BUILD_HEADLESS), true)
$(CUPS_CFLAGS) \
$(X_CFLAGS) \
$(LIBAWT_HEADLESS_CFLAGS), \
DISABLED_WARNINGS_xlc := 1506-356, \
DISABLED_WARNINGS_gcc := maybe-uninitialized int-to-pointer-cast, \
DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE \
E_EMPTY_TRANSLATION_UNIT, \
@ -603,6 +605,10 @@ ifeq ($(BUILD_HEADLESS), true)
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_headless, \
))
# AIX warning explanation:
# 1506-356 : (W) Compilation unit is empty.
# This happens during the headless build
$(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
TARGETS += $(BUILD_LIBAWT_HEADLESS)
@ -700,6 +706,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBFONTMANAGER_CFLAGS), \
OPTIMIZATION := $(LIBFONTMANAGER_OPTIMIZATION), \
CFLAGS_windows = -DCC_NOEX, \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := sign-compare int-to-pointer-cast \
type-limits missing-field-initializers, \
DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \

View File

@ -146,6 +146,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \
$(LIBJAVA_CFLAGS), \
System.c_CFLAGS := $(VERSION_CFLAGS), \
jdk_util.c_CFLAGS := $(VERSION_CFLAGS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := unused-result, \
DISABLED_WARNINGS_solstudio := E_STATEMENT_NOT_REACHED, \
MAPFILE := $(LIBJAVA_MAPFILE), \
@ -289,7 +290,7 @@ LIBJLI_SRC_DIRS := $(call FindSrcDirsForLib, java.base, jli)
LIBJLI_CFLAGS := $(CFLAGS_JDKLIB)
ifeq ($(JVM_VARIANT_ZERO), true)
ifeq ($(call check-jvm-variant, zero zeroshark), true)
ERGO_FAMILY := zero
else
ifeq ($(OPENJDK_TARGET_CPU_ARCH), x86)

View File

@ -70,6 +70,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBNIO, \
SRC := $(BUILD_LIBNIO_SRC), \
EXCLUDE_FILES := $(BUILD_LIBNIO_EXFILES), \
OPTIMIZATION := HIGH, \
WARNINGS_AS_ERRORS_xlc := false, \
CFLAGS := $(CFLAGS_JDKLIB) \
$(BUILD_LIBNIO_CFLAGS), \
MAPFILE := $(BUILD_LIBNIO_MAPFILE), \

View File

@ -139,8 +139,7 @@ SUNWprivate_1.1 {
Java_java_lang_Double_doubleToRawLongBits;
Java_java_lang_Float_intBitsToFloat;
Java_java_lang_Float_floatToRawIntBits;
Java_java_lang_StackFrameInfo_fillInStackFrames;
Java_java_lang_StackFrameInfo_setMethodInfo;
Java_java_lang_StackFrameInfo_toStackTraceElement0;
Java_java_lang_StackStreamFactory_checkStackWalkModes;
Java_java_lang_StackStreamFactory_00024AbstractStackWalker_callStackWalk;
Java_java_lang_StackStreamFactory_00024AbstractStackWalker_fetchStackFrames;

View File

@ -37,24 +37,14 @@ class StackFrameInfo implements StackFrame {
private final static JavaLangInvokeAccess jlInvokeAccess =
SharedSecrets.getJavaLangInvokeAccess();
// -XX:+MemberNameInStackFrame will initialize MemberName and all other fields;
// otherwise, VM will set the hidden fields (injected by the VM).
// -XX:+MemberNameInStackFrame is temporary to enable performance measurement
//
// Footprint improvement: MemberName::clazz and MemberName::name
// can replace StackFrameInfo::declaringClass and StackFrameInfo::methodName
// Currently VM sets StackFrameInfo::methodName instead of expanding MemberName::name
// Footprint improvement: MemberName::clazz can replace
// StackFrameInfo::declaringClass.
final StackWalker walker;
final Class<?> declaringClass;
final Object memberName;
final int bci;
// methodName, fileName, and lineNumber will be lazily set by the VM
// when first requested.
private String methodName;
private String fileName = null; // default for unavailable filename
private int lineNumber = -1; // default for unavailable lineNumber
final short bci;
private volatile StackTraceElement ste;
/*
* Create StackFrameInfo for StackFrameTraverser and LiveStackFrameTraverser
@ -78,77 +68,53 @@ class StackFrameInfo implements StackFrame {
return declaringClass;
}
// Call the VM to set methodName, lineNumber, and fileName
private synchronized void ensureMethodInfoInitialized() {
if (methodName == null) {
setMethodInfo();
}
}
@Override
public String getMethodName() {
ensureMethodInfoInitialized();
return methodName;
return jlInvokeAccess.getName(memberName);
}
@Override
public Optional<String> getFileName() {
ensureMethodInfoInitialized();
return fileName != null ? Optional.of(fileName) : Optional.empty();
public final Optional<String> getFileName() {
StackTraceElement ste = toStackTraceElement();
return ste.getFileName() != null ? Optional.of(ste.getFileName()) : Optional.empty();
}
@Override
public OptionalInt getLineNumber() {
ensureMethodInfoInitialized();
return lineNumber > 0 ? OptionalInt.of(lineNumber) : OptionalInt.empty();
public final OptionalInt getLineNumber() {
StackTraceElement ste = toStackTraceElement();
return ste.getLineNumber() > 0 ? OptionalInt.of(ste.getLineNumber()) : OptionalInt.empty();
}
@Override
public boolean isNativeMethod() {
ensureMethodInfoInitialized();
return lineNumber == -2;
public final boolean isNativeMethod() {
StackTraceElement ste = toStackTraceElement();
return ste.isNativeMethod();
}
@Override
public String toString() {
ensureMethodInfoInitialized();
// similar format as StackTraceElement::toString
if (isNativeMethod()) {
return getClassName() + "." + getMethodName() + "(Native Method)";
} else {
// avoid allocating Optional objects
return getClassName() + "." + getMethodName() +
"(" + (fileName != null ? fileName : "Unknown Source") +
(lineNumber > 0 ? ":" + lineNumber : " bci:" + bci) + ")";
}
StackTraceElement ste = toStackTraceElement();
return ste.toString();
}
/**
* Lazily initialize method name, file name, line number
* Fill in the fields of the given StackTraceElement
*/
private native void setMethodInfo();
/**
* Fill in source file name and line number of the given StackFrame array.
*/
static native void fillInStackFrames(int startIndex,
Object[] stackframes,
int fromIndex, int toIndex);
private native void toStackTraceElement0(StackTraceElement ste);
@Override
public StackTraceElement toStackTraceElement() {
ensureMethodInfoInitialized();
Module module = declaringClass.getModule();
String moduleName = module.isNamed() ? module.getName() : null;
String moduleVersion = null;
if (module.isNamed() && module.getDescriptor().version().isPresent()) {
moduleVersion = module.getDescriptor().version().get().toString();
StackTraceElement s = ste;
if (s == null) {
synchronized (this) {
s = ste;
if (s == null) {
s = new StackTraceElement();
toStackTraceElement0(s);
ste = s;
}
}
}
return new StackTraceElement(moduleName, moduleVersion,
getClassName(), getMethodName(),
fileName,
lineNumber);
return s;
}
}

View File

@ -1388,7 +1388,7 @@ class Thread implements Runnable {
* This method is used only for debugging.
*/
public static void dumpStack() {
StackStreamFactory.makeStackTrace().printStackTrace(System.err);
new Exception("Stack trace").printStackTrace();
}
/**
@ -1610,8 +1610,7 @@ class Thread implements Runnable {
}
return stackTrace;
} else {
// Don't need JVM help for current thread
return StackStreamFactory.makeStackTrace().getStackTraceElements();
return (new Exception()).getStackTrace();
}
}

View File

@ -785,11 +785,7 @@ public class Throwable implements Serializable {
public synchronized Throwable fillInStackTrace() {
if (stackTrace != null ||
backtrace != null /* Out of protocol state */ ) {
if (backtrace == null && StackStreamFactory.useStackTrace(this)) {
backtrace = StackStreamFactory.makeStackTrace(this);
} else {
fillInStackTrace(0);
}
fillInStackTrace(0);
stackTrace = UNASSIGNED_STACK;
}
return this;
@ -830,15 +826,11 @@ public class Throwable implements Serializable {
// backtrace if this is the first call to this method
if (stackTrace == UNASSIGNED_STACK ||
(stackTrace == null && backtrace != null) /* Out of protocol state */) {
if (backtrace instanceof StackStreamFactory.StackTrace) {
stackTrace = ((StackStreamFactory.StackTrace)backtrace).getStackTraceElements();
} else {
stackTrace = new StackTraceElement[depth];
for (int i = 0; i < depth; i++) {
stackTrace[i] = new StackTraceElement();
}
getStackTraceElements(stackTrace);
stackTrace = new StackTraceElement[depth];
for (int i = 0; i < depth; i++) {
stackTrace[i] = new StackTraceElement();
}
getStackTraceElements(stackTrace);
} else if (stackTrace == null) {
return UNASSIGNED_STACK;
}

View File

@ -1132,6 +1132,10 @@ import java.util.Objects;
public Object newMemberName() {
return new MemberName();
}
public String getName(Object mname) {
MemberName memberName = (MemberName)mname;
return memberName.getName();
}
});
}
}

View File

@ -30,4 +30,9 @@ public interface JavaLangInvokeAccess {
* Create a new MemberName instance
*/
Object newMemberName();
/**
* Returns the name for the given MemberName
*/
String getName(Object mname);
}

View File

@ -179,7 +179,6 @@ JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray elements)
*/
enum {
JVM_STACKWALK_FILL_CLASS_REFS_ONLY = 0x2,
JVM_STACKWALK_FILTER_FILL_IN_STACK_TRACE = 0x10,
JVM_STACKWALK_SHOW_HIDDEN_FRAMES = 0x20,
JVM_STACKWALK_FILL_LIVE_STACK_FRAMES = 0x100
};
@ -187,23 +186,15 @@ enum {
JNIEXPORT jobject JNICALL
JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode,
jint skip_frames, jint frame_count, jint start_index,
jobjectArray classes,
jobjectArray frames);
JNIEXPORT jint JNICALL
JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
jint frame_count, jint start_index,
jobjectArray classes,
jobjectArray frames);
JNIEXPORT void JNICALL
JVM_FillStackFrames(JNIEnv* env, jclass cls,
jint start_index,
jobjectArray stackFrames,
jint from_index, jint toIndex);
JNIEXPORT void JNICALL
JVM_SetMethodInfo(JNIEnv* env, jobject frame);
JVM_ToStackTraceElement(JNIEnv* env, jobject frame, jobject stackElement);
JNIEXPORT jobjectArray JNICALL
JVM_GetVmArguments(JNIEnv *env);

View File

@ -38,22 +38,10 @@
/*
* Class: java_lang_StackFrameInfo
* Method: fillInStackFrames
* Signature: (I[Ljava/lang/Object;[Ljava/lang/Object;II)V
* Method: toStackTraceElement0
* Signature: (Ljava/lang/StackTraceElement;)V
*/
JNIEXPORT void JNICALL Java_java_lang_StackFrameInfo_fillInStackFrames
(JNIEnv *env, jclass dummy, jint startIndex,
jobjectArray stackFrames, jint fromIndex, jint toIndex) {
JVM_FillStackFrames(env, dummy, startIndex,
stackFrames, fromIndex, toIndex);
}
/*
* Class: java_lang_StackFrameInfo
* Method: setMethodInfo
* Signature: (Ljava/lang/Class;)V
*/
JNIEXPORT void JNICALL Java_java_lang_StackFrameInfo_setMethodInfo
(JNIEnv *env, jobject stackframeinfo) {
JVM_SetMethodInfo(env, stackframeinfo);
JNIEXPORT void JNICALL Java_java_lang_StackFrameInfo_toStackTraceElement0
(JNIEnv *env, jobject stackframeinfo, jobject stacktraceinfo) {
JVM_ToStackTraceElement(env, stackframeinfo, stacktraceinfo);
}

View File

@ -45,7 +45,6 @@ JNIEXPORT jboolean JNICALL Java_java_lang_StackStreamFactory_checkStackWalkModes
(JNIEnv *env, jclass dummy)
{
return JVM_STACKWALK_FILL_CLASS_REFS_ONLY == java_lang_StackStreamFactory_FILL_CLASS_REFS_ONLY &&
JVM_STACKWALK_FILTER_FILL_IN_STACK_TRACE == java_lang_StackStreamFactory_FILTER_FILL_IN_STACKTRACE &&
JVM_STACKWALK_SHOW_HIDDEN_FRAMES == java_lang_StackStreamFactory_SHOW_HIDDEN_FRAMES &&
JVM_STACKWALK_FILL_LIVE_STACK_FRAMES == java_lang_StackStreamFactory_FILL_LIVE_STACK_FRAMES;
}
@ -53,26 +52,26 @@ JNIEXPORT jboolean JNICALL Java_java_lang_StackStreamFactory_checkStackWalkModes
/*
* Class: java_lang_StackStreamFactory_AbstractStackWalker
* Method: callStackWalk
* Signature: (JIII[Ljava/lang/Class;[Ljava/lang/StackWalker/StackFrame;)Ljava/lang/Object;
* Signature: (JIII[Ljava/lang/Object;)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_java_lang_StackStreamFactory_00024AbstractStackWalker_callStackWalk
(JNIEnv *env, jobject stackstream, jlong mode, jint skipFrames, jint batchSize, jint startIndex,
jobjectArray classes, jobjectArray frames)
jobjectArray frames)
{
return JVM_CallStackWalk(env, stackstream, mode, skipFrames, batchSize,
startIndex, classes, frames);
startIndex, frames);
}
/*
* Class: java_lang_StackStreamFactory_AbstractStackWalker
* Method: fetchStackFrames
* Signature: (JJII[Ljava/lang/Class;[Ljava/lang/StackWalker/StackFrame;)I
* Signature: (JJII[Ljava/lang/Object;)I
*/
JNIEXPORT jint JNICALL Java_java_lang_StackStreamFactory_00024AbstractStackWalker_fetchStackFrames
(JNIEnv *env, jobject stackstream, jlong mode, jlong anchor,
jint batchSize, jint startIndex,
jobjectArray classes, jobjectArray frames)
jobjectArray frames)
{
return JVM_MoreStackWalk(env, stackstream, mode, anchor, batchSize,
startIndex, classes, frames);
startIndex, frames);
}

View File

@ -335,10 +335,6 @@ com/sun/jdi/CatchPatternTest.sh 8068645 generic-
com/sun/jdi/GetLocalVariables4Test.sh 8067354 windows-all
com/sun/jdi/InterfaceMethodsTest.java 8152586 generic-all
com/sun/jdi/InvokeTest.java 8152586 generic-all
############################################################################
# jdk_util

View File

@ -924,7 +924,7 @@ dojstack()
# If jstack exists, so will jps
# Show stack traces of jdb and debuggee as a possible debugging aid.
jdbCmd=`$jdk/bin/jps -v | $grep $jdbKeyword`
realJdbPid=`echo "$jdbCmd" | sed -e 's@ TTY.*@@'`
realJdbPid=`echo "$jdbCmd" | sed -e 's@ .*@@'`
if [ ! -z "$realJdbPid" ] ; then
echo "-- jdb process info ----------------------" >&2
echo " $jdbCmd" >&2

View File

@ -0,0 +1,97 @@
/*
* Copyright (c) 2016, 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.
*/
import com.sun.jdi.connect.*;
import com.sun.jdi.*;
import java.util.Map;
import java.util.List;
import jdk.test.lib.Asserts;
/*
* @test
* @summary Verifies that PathSearchingVirtualMachine.bootClassPath()
* returns an empty list in case no bootclass path specified
* regardless of sun.boot.class.path option, which is now obsolete
* @library /test/lib/share/classes
* @compile TestClass.java
* @compile SunBootClassPathEmptyTest.java
* @run main/othervm SunBootClassPathEmptyTest
*/
public class SunBootClassPathEmptyTest {
/**
* Helper class to facilitate the debuggee VM launching
*/
private static class VmConnector {
LaunchingConnector lc;
VirtualMachine vm;
VmConnector() {
for (LaunchingConnector c : Bootstrap.virtualMachineManager().launchingConnectors()) {
System.out.println("name: " + c.name());
if (c.name().equals("com.sun.jdi.CommandLineLaunch")) {
lc = c;
break;
}
}
if (lc == null) {
throw new RuntimeException("Connector not found");
}
}
PathSearchingVirtualMachine launchVm(String cmdLine, String options) throws Exception {
Map<String, Connector.Argument> vmArgs = lc.defaultArguments();
vmArgs.get("main").setValue(cmdLine);
if (options != null) {
vmArgs.get("options").setValue(options);
}
System.out.println("Debugger is launching vm ...");
vm = lc.launch(vmArgs);
if (!(vm instanceof PathSearchingVirtualMachine)) {
throw new RuntimeException("VM is not a PathSearchingVirtualMachine");
}
return (PathSearchingVirtualMachine) vm;
}
}
private static VmConnector connector = new VmConnector();
public static void main(String[] args) throws Exception {
testWithObsoleteClassPathOption(null);
testWithObsoleteClassPathOption("someclasspath");
}
private static void testWithObsoleteClassPathOption(String obsoleteClassPath) throws Exception {
PathSearchingVirtualMachine vm = connector.launchVm("TestClass", makeClassPathOptions(obsoleteClassPath));
List<String> bootClassPath = vm.bootClassPath();
Asserts.assertNotNull(bootClassPath, "Expected bootClassPath to be empty but was null");
Asserts.assertEquals(0, bootClassPath.size(), "Expected bootClassPath.size() 0 but was: " + bootClassPath.size());
}
private static String makeClassPathOptions(String obsoleteClassPath) {
return obsoleteClassPath == null ? null : "-Dsun.boot.class.path=" + obsoleteClassPath;
}
}

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2016, 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.
*/
public class TestClass {
public static void main(String[] args) {
System.out.println("This is a test");
}
}

View File

@ -28,9 +28,6 @@
* This test should also been run against jdk9 successfully except of
* VM option MemberNameInStackFrame.
* @run main/othervm DumpStackTest
* @run main/othervm -Dstackwalk.newThrowable=false DumpStackTest
* @run main/othervm -Dstackwalk.newThrowable=true -XX:-MemberNameInStackFrame DumpStackTest
* @run main/othervm -Dstackwalk.newThrowable=true -XX:+MemberNameInStackFrame DumpStackTest
*/
import java.lang.invoke.MethodHandle;

View File

@ -25,8 +25,7 @@
* @test
* @bug 8140450
* @summary Basic test for StackWalker.getCallerClass()
* @run main/othervm -XX:-MemberNameInStackFrame GetCallerClassTest
* @run main/othervm -XX:+MemberNameInStackFrame GetCallerClassTest
* @run main/othervm GetCallerClassTest
* @run main/othervm GetCallerClassTest sm
*/

View File

@ -44,10 +44,6 @@ import jdk.testlibrary.RandomFactory;
* @run main/othervm/java.security.policy=stackwalktest.policy StackWalkTest
* @run main/othervm StackWalkTest -random:50
* @run main/othervm/java.security.policy=stackwalktest.policy StackWalkTest -random:50
* @run main/othervm -XX:-MemberNameInStackFrame -Dstackwalk.newThrowable=false StackWalkTest -random:50
* @run main/othervm -XX:-MemberNameInStackFrame -Dstackwalk.newThrowable=true StackWalkTest -random:50
* @run main/othervm -XX:+MemberNameInStackFrame -Dstackwalk.newThrowable=false StackWalkTest -random:50
* @run main/othervm -XX:+MemberNameInStackFrame -Dstackwalk.newThrowable=true StackWalkTest -random:50
* @author danielfuchs, bchristi
* @key randomness
*/

View File

@ -40,8 +40,7 @@ import static java.lang.StackWalker.Option.*;
* @summary Verify stack trace information obtained with respect to StackWalker
* options, when the stack contains lambdas, method handle invoke
* virtual calls, and reflection.
* @run main/othervm -XX:-MemberNameInStackFrame VerifyStackTrace
* @run main/othervm -XX:+MemberNameInStackFrame VerifyStackTrace
* @run main/othervm VerifyStackTrace
* @run main/othervm/java.security.policy=stackwalk.policy VerifyStackTrace
* @author danielfuchs
*/