diff --git a/make/test/JtregNativeHotspot.gmk b/make/test/JtregNativeHotspot.gmk index 1c4150f7d70..62cca6a433c 100644 --- a/make/test/JtregNativeHotspot.gmk +++ b/make/test/JtregNativeHotspot.gmk @@ -63,6 +63,21 @@ NSK_MONITORING_INCLUDES := \ -I$(VM_TESTBASE_DIR)/nsk/share/native \ -I$(VM_TESTBASE_DIR)/nsk/share/jni +NSK_JDI_INCLUDES := \ + -I$(VM_TESTBASE_DIR)/nsk/share/native + +NSK_SHARE_JDI_INCLUDES := \ + -I$(VM_TESTBASE_DIR)/nsk/share/native \ + -I$(VM_TESTBASE_DIR)/nsk/share/jdi + +NSK_SHARE_JNI_INCLUDES := \ + -I$(VM_TESTBASE_DIR)/nsk/share/native \ + -I$(VM_TESTBASE_DIR)/nsk/share/jni + +NSK_SHARE_LOCKS_INCLUDES := \ + -I$(VM_TESTBASE_DIR)/nsk/share/native \ + -I$(VM_TESTBASE_DIR)/nsk/share/locks + BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libProcessUtils := $(VM_SHARE_INCLUDES) BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libThreadController := $(NSK_MONITORING_INCLUDES) @@ -71,6 +86,15 @@ BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libRecursiveMonitoringThread := $(NSK_MONIT BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libLockingThreads := $(NSK_MONITORING_INCLUDES) BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libStackTraceController := $(NSK_MONITORING_INCLUDES) +BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libforceEarlyReturn005a := $(NSK_JDI_INCLUDES) + +BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libMonitorEnterExecutor := $(NSK_SHARE_JDI_INCLUDES) + +BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libJNIreferences := $(NSK_SHARE_JNI_INCLUDES) + +BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libLockingThread := $(NSK_SHARE_LOCKS_INCLUDES) +BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libJNIMonitorLocker := $(NSK_SHARE_LOCKS_INCLUDES) + ################################################################################ # Platform specific setup diff --git a/test/hotspot/jtreg/ProblemList-graal.txt b/test/hotspot/jtreg/ProblemList-graal.txt index 6b4700d91f2..bdd9846e286 100644 --- a/test/hotspot/jtreg/ProblemList-graal.txt +++ b/test/hotspot/jtreg/ProblemList-graal.txt @@ -84,3 +84,54 @@ compiler/jvmci/meta/StableFieldTest.java CODETOOLS-790216 compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java CODETOOLS-7902162 generic-all compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java CODETOOLS-7902162 generic-all compiler/jvmci/events/JvmciShutdownEventTest.java CODETOOLS-7902162 generic-all + +vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn009/forceEarlyReturn009.java 8191047 generic-all + +vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012/TestDescription.java 8195600 generic-all +vmTestbase/nsk/jdi/ClassType/setValue/setvalue006/TestDescription.java 8195600 generic-all +vmTestbase/nsk/jdi/ListeningConnector/listennosuspend/listennosuspend001/TestDescription.java 8195600 generic-all +vmTestbase/nsk/jdi/Location/lineNumber_s/lineNumber_s002/lineNumber_s002.java 8195600 generic-all +vmTestbase/nsk/jdi/Location/sourcePath_s/sourcePath_s002/sourcePath_s002.java 8195600 generic-all +vmTestbase/nsk/jdi/Method/allLineLocations_ss/allLineLocations_ss003/allLineLocations_ss003.java 8195600 generic-all +vmTestbase/nsk/jdi/Method/locationsOfLine_ssi/locationsOfLine_ssi003/locationsOfLine_ssi003.java 8195600 generic-all +vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011/TestDescription.java 8195600 generic-all +vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod012/TestDescription.java 8195600 generic-all +vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects001/referringObjects001.java 8195600 generic-all +vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects002/referringObjects002.java 8195600 generic-all +vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects004/referringObjects004.java 8195600 generic-all +vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue005/TestDescription.java 8195600 generic-all +vmTestbase/nsk/jdi/ReferenceType/instances/instances001/instances001.java 8195600 generic-all +vmTestbase/nsk/jdi/ReferenceType/instances/instances002/instances002.java 8195600 generic-all +vmTestbase/nsk/jdi/ReferenceType/instances/instances005/instances005.java 8195600 generic-all +vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn007/TestDescription.java 8195600 generic-all +vmTestbase/nsk/jdi/ThreadReference/ownedMonitorsAndFrames/ownedMonitorsAndFrames001/ownedMonitorsAndFrames001.java 8195600 generic-all +vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001.java 8195600 generic-all +vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java 8195600 generic-all +vmTestbase/nsk/jdi/stress/serial/ownedMonitorsAndFrames002/TestDescription.java 8195600 generic-all +vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn003/forceEarlyReturn003.java 8195600 generic-all +vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn004/forceEarlyReturn004.java 8195600 generic-all + +vmTestbase/nsk/jdi/Location/sourceName_s/sourceName_s002/sourceName_s002.java 8200387 generic-all +vmTestbase/nsk/jdi/Method/allLineLocations_ss/allLineLocations_ss002/allLineLocations_ss002.java 8200387 generic-all +vmTestbase/nsk/jdi/Method/locationsOfLine_ssi/locationsOfLine_ssi002/locationsOfLine_ssi002.java 8200387 generic-all +vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects003/referringObjects003.java 8200387 generic-all +vmTestbase/nsk/jdi/ReferenceType/allLineLocations_ss/allLineLocations_ss003/allLineLocations_ss003.java 8200387 generic-all +vmTestbase/nsk/jdi/ReferenceType/allLineLocations_ss/allLineLocations_ss004/allLineLocations_ss004.java 8200387 generic-all +vmTestbase/nsk/jdi/ReferenceType/availableStrata/availableStrata002/availableStrata002.java 8200387 generic-all +vmTestbase/nsk/jdi/ReferenceType/defaultStratum/defaultStratum002/defaultStratum002.java 8200387 generic-all +vmTestbase/nsk/jdi/ReferenceType/locationsOfLine_ssi/locationsOfLine_ssi003/locationsOfLine_ssi003.java 8200387 generic-all +vmTestbase/nsk/jdi/ReferenceType/locationsOfLine_ssi/locationsOfLine_ssi004/locationsOfLine_ssi004.java 8200387 generic-all +vmTestbase/nsk/jdi/ReferenceType/sourceNames/sourceNames003/sourceNames003.java 8200387 generic-all +vmTestbase/nsk/jdi/ReferenceType/sourcePaths/sourcePaths003/sourcePaths003.java 8200387 generic-all +vmTestbase/nsk/jdi/StackFrame/getArgumentValues/getArgumentValues002/getArgumentValues002.java 8200387 generic-all +vmTestbase/nsk/jdi/StackFrame/getArgumentValues/getArgumentValues003/getArgumentValues003.java 8200387 generic-all +vmTestbase/nsk/jdi/stress/serial/heapwalking001/TestDescription.java 8200387 generic-all +vmTestbase/nsk/jdi/ThreadReference/ownedMonitorsAndFrames/ownedMonitorsAndFrames004/ownedMonitorsAndFrames004.java 8200387 generic-all +vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts001/instancecounts001.java 8200387 generic-all +vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts002/TestDescription.java 8200387 generic-all +vmTestbase/nsk/jdi/VirtualMachine/setDefaultStratum/setDefaultStratum002/setDefaultStratum002.java 8200387 generic-all + +vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses026/TestDescription.java 8195627 generic-all +vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses028/TestDescription.java 8195627 generic-all +vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses030/TestDescription.java 8195627 generic-all + diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 9de4220fd01..2f550390570 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -109,4 +109,18 @@ vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded004 vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005/TestDescription.java 8153598 generic-all vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestDescription.java 8060733 generic-all +vmTestbase/nsk/jdi/AttachingConnector/attachnosuspend/attachnosuspend001/TestDescription.java 8153613 generic-all +vmTestbase/nsk/jdi/ThreadReference/frameCount/framecount001/TestDescription.java 6530620 generic-all +vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended002/TestDescription.java 4903717 generic-all +vmTestbase/nsk/jdi/ThreadReference/resume/resume001/TestDescription.java 8072701 generic-all +vmTestbase/nsk/jdi/ThreadReference/stop/stop001/TestDescription.java 7034630 generic-all +vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001/TestDescription.java 8013728 generic-all +vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004/TestDescription.java 4751860 generic-all +vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003/TestDescription.java 8066993 generic-all +vmTestbase/nsk/jdi/StackFrame/_bounds_/bounds001/TestDescription.java 6604963 generic-all +vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses021/TestDescription.java 8065773 generic-all +vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses023/TestDescription.java 8065773 generic-all +vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l005/TestDescription.java 8068225 generic-all +vmTestbase/nsk/jdi/stress/ClassPrepareEvents/ClassPrepareEvents001/ClassPrepareEvents001.java 6426321 generic-all + ############################################################################# diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index d6ff348014c..42835663663 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -587,4 +587,565 @@ vmTestbase_nsk_monitoring_quick = \ vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_proxy_default/TestDescription.java \ vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_proxy_custom/TestDescription.java +# JDI tests +vmTestbase_nsk_jdi = \ + vmTestbase/nsk/jdi + +vmTestbase_nsk_jdi_quick = \ + vmTestbase/nsk/jdi/Argument/description/description001/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/isValid/isvalid001/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/isValid/isvalid002/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/isValid/isvalid003/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/isValid/isvalid004/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/isValid/isvalid005/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/name/name001/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/value/value001/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/value/value002/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/value/value003/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/setValue/setvalue001/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/setValue/setvalue002/TestDescription.java \ + vmTestbase/nsk/jdi/Argument/mustSpecify/mustspecify001/TestDescription.java \ + vmTestbase/nsk/jdi/AttachingConnector/attach/attach002/TestDescription.java \ + vmTestbase/nsk/jdi/BooleanArgument/booleanValue/booleanvalue001/TestDescription.java \ + vmTestbase/nsk/jdi/BooleanArgument/booleanValue/booleanvalue002/TestDescription.java \ + vmTestbase/nsk/jdi/BooleanArgument/isValid/isvalid001/TestDescription.java \ + vmTestbase/nsk/jdi/BooleanArgument/isValid/isvalid002/TestDescription.java \ + vmTestbase/nsk/jdi/BooleanArgument/setValue/setvalue001/TestDescription.java \ + vmTestbase/nsk/jdi/BooleanArgument/setValue/setvalue002/TestDescription.java \ + vmTestbase/nsk/jdi/BooleanArgument/stringValueOf/stringvalueof001/TestDescription.java \ + vmTestbase/nsk/jdi/BooleanArgument/stringValueOf/stringvalueof002/TestDescription.java \ + vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001/TestDescription.java \ + vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses002/TestDescription.java \ + vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses003/TestDescription.java \ + vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses004/TestDescription.java \ + vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses005/TestDescription.java \ + vmTestbase/nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses002/TestDescription.java \ + vmTestbase/nsk/jdi/Connector/defaultArguments/defaultArguments001/TestDescription.java \ + vmTestbase/nsk/jdi/Connector/defaultArguments/defaultArguments002/TestDescription.java \ + vmTestbase/nsk/jdi/Connector/defaultArguments/defaultArguments003/TestDescription.java \ + vmTestbase/nsk/jdi/Connector/description/description001/TestDescription.java \ + vmTestbase/nsk/jdi/Connector/name/name001/TestDescription.java \ + vmTestbase/nsk/jdi/Connector/transport/transport001/TestDescription.java \ + vmTestbase/nsk/jdi/FloatValue/compareTo/compareto001/TestDescription.java \ + vmTestbase/nsk/jdi/IntegerArgument/intValue/intvalue001/TestDescription.java \ + vmTestbase/nsk/jdi/IntegerArgument/intValue/intvalue002/TestDescription.java \ + vmTestbase/nsk/jdi/IntegerArgument/isValid/isvalid001/TestDescription.java \ + vmTestbase/nsk/jdi/IntegerArgument/isValid/isvalid002/TestDescription.java \ + vmTestbase/nsk/jdi/IntegerArgument/isValid/isvalid003/TestDescription.java \ + vmTestbase/nsk/jdi/IntegerArgument/max/max001/TestDescription.java \ + vmTestbase/nsk/jdi/IntegerArgument/min/min001/TestDescription.java \ + vmTestbase/nsk/jdi/IntegerArgument/setValue/setvalue001/TestDescription.java \ + vmTestbase/nsk/jdi/IntegerArgument/stringValueOf/stringvalueof001/TestDescription.java \ + vmTestbase/nsk/jdi/IntegerValue/compareTo/compareto001/TestDescription.java \ + vmTestbase/nsk/jdi/LaunchingConnector/launch/launch001/TestDescription.java \ + vmTestbase/nsk/jdi/LaunchingConnector/launch/launch002/TestDescription.java \ + vmTestbase/nsk/jdi/LaunchingConnector/launch/launch004/TestDescription.java \ + vmTestbase/nsk/jdi/ListeningConnector/accept/accept001/TestDescription.java \ + vmTestbase/nsk/jdi/ListeningConnector/accept/accept002/TestDescription.java \ + vmTestbase/nsk/jdi/ListeningConnector/stopListening/stoplis001/TestDescription.java \ + vmTestbase/nsk/jdi/ListeningConnector/supportsMultipleConnections/supportsmultipleconnections001/TestDescription.java \ + vmTestbase/nsk/jdi/ListeningConnector/listennosuspend/listennosuspend001/TestDescription.java \ + vmTestbase/nsk/jdi/LongValue/compareTo/compareto001/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/entryCount/entrycount002/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/owningThread/owningthread002/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/waitingThreads/waitingthreads002/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/waitingThreads/waitingthreads003/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/waitingThreads/waitingthreads004/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/isVerified/isverified003/TestDescription.java \ + vmTestbase/nsk/jdi/SelectedArgument/choices/choices001/TestDescription.java \ + vmTestbase/nsk/jdi/SelectedArgument/isValid/isvalid001/TestDescription.java \ + vmTestbase/nsk/jdi/SelectedArgument/isValid/isvalid002/TestDescription.java \ + vmTestbase/nsk/jdi/ShortType/_itself_/shorttype001/TestDescription.java \ + vmTestbase/nsk/jdi/ShortValue/compareTo/compareto001/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/thisObject/thisobject002/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/thread/thread001/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/visibleVariableByName/visiblevarbyname001/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/visibleVariableByName/visiblevarbyname002/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/visibleVariables/visiblevariables001/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/visibleVariables/visiblevariables002/TestDescription.java \ + vmTestbase/nsk/jdi/StepEvent/_itself_/stepevent001/TestDescription.java \ + vmTestbase/nsk/jdi/StepEvent/_itself_/stepevent002/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addClassExclusionFilter/filter001/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addClassExclusionFilter/filter002/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s001/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt001/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/depth/depth001/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/depth/depth002/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/depth/depth003/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/size/size001/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/size/size002/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/thread/thread001/TestDescription.java \ + vmTestbase/nsk/jdi/StringArgument/isValid/isvalid001/TestDescription.java \ + vmTestbase/nsk/jdi/StringArgument/isValid/isvalid002/TestDescription.java \ + vmTestbase/nsk/jdi/StringArgument/isValid/isvalid003/TestDescription.java \ + vmTestbase/nsk/jdi/StringReference/value/value001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadDeathEvent/thread/thread001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter002/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter003/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter004/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter005/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadGroupReference/name/name001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadGroupReference/parent/parent001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadGroupReference/resume/resume001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadGroupReference/suspend/suspend001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadGroupReference/threadGroups/threadgroups001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadGroupReference/threads/threads001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/frame/frame001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/frameCount/framecount001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/frames/frames001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/frames_ii/frames_ii002/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/isAtBreakpoint/isatbreakpoint001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended003/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended004/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/name/name001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/ownedMonitors/ownedmonitors001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/suspendCount/suspendcount001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/threadGroup/threadgroup001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/currentContendedMonitor/currentcm001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/interrupt/interrupt001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/resume/resume001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/status/status003/status003.java \ + vmTestbase/nsk/jdi/ThreadReference/status/status004/status004.java \ + vmTestbase/nsk/jdi/ThreadReference/status/status005/status005.java \ + vmTestbase/nsk/jdi/ThreadReference/status/status006/status006.java \ + vmTestbase/nsk/jdi/ThreadReference/status/status007/status007.java \ + vmTestbase/nsk/jdi/ThreadReference/status/status008/status008.java \ + vmTestbase/nsk/jdi/ThreadReference/stop/stop001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter002/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter003/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter004/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter005/TestDescription.java \ + vmTestbase/nsk/jdi/Transport/name/name001/TestDescription.java \ + vmTestbase/nsk/jdi/Type/name/name001/TestDescription.java \ + vmTestbase/nsk/jdi/Type/name/name002/TestDescription.java \ + vmTestbase/nsk/jdi/Type/name/name003/TestDescription.java \ + vmTestbase/nsk/jdi/Type/signature/signature001/TestDescription.java \ + vmTestbase/nsk/jdi/Type/signature/signature002/TestDescription.java \ + vmTestbase/nsk/jdi/Type/signature/signature003/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/declaringType/decltype001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/declaringType/decltype002/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/declaringType/decltype003/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/declaringType/decltype007/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/declaringType/decltype008/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isFinal/isfinal001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isFinal/isfinal003/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isStatic/isstatic001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isStatic/isstatic003/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isSynthetic/issynthetic001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isSynthetic/issynthetic002/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/name/name001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/name/name003/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/signature/sign001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/signature/sign003/TestDescription.java \ + vmTestbase/nsk/jdi/Value/type/type001/TestDescription.java \ + vmTestbase/nsk/jdi/Value/type/type002/type002.java \ + vmTestbase/nsk/jdi/Value/type/type003/TestDescription.java \ + vmTestbase/nsk/jdi/Value/_itself_/value001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses002/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/allThreads/allthreads001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canGetBytecodes/cangetbytecodes001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canGetCurrentContendedMonitor/cangccm001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canGetMonitorInfo/cangetmonitorinfo001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canGetOwnedMonitorInfo/cangetinfo001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canGetSyntheticAttribute/cangetattr001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldAccess/canwatchaccess001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldModification/canwatchmod001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/classesByName/classesbyname001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/description/description001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/eventQueue/eventqueue001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/eventRequestManager/eventrmanager001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/exit/exit001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/exit/exit002/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/mirrorOf_bool/mirrorof_bool001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/mirrorOf_byte/mirrorof_byte001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/mirrorOf_char/mirrorof_char001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/mirrorOf_double/mirrorof_double001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/mirrorOf_float/mirrorof_float001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/mirrorOf_int/mirrorof_int001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/mirrorOf_long/mirrorof_long001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/mirrorOf_short/mirrorof_short001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/mirrorOf_string/mirrorof_string001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/name/name001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/process/process001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/topLevelThreadGroups/toplevelgroups001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/version/version001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/allConnectors/allconnectors001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/attachingConnectors/attaching001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/connectedVirtualMachines/convm001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/connectedVirtualMachines/convm002/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/connectedVirtualMachines/convm003/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/defaultConnector/default001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/launchingConnectors/launching001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/listeningConnectors/listening001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/majorInterfaceVersion/major001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/minorInterfaceVersion/minor001/TestDescription.java \ + vmTestbase/nsk/jdi/VoidType/_itself_/voidtype001/TestDescription.java \ + vmTestbase/nsk/jdi/VoidValue/equals/equals001/equals001.java \ + vmTestbase/nsk/jdi/VoidValue/hashCode/hashcode001/hashcode001.java \ + vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath001/TestDescription.java \ + vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath002/TestDescription.java \ + vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath003/TestDescription.java \ + vmTestbase/nsk/jdi/VMDisconnectEvent/_itself_/disconnect001/TestDescription.java \ + vmTestbase/nsk/jdi/VMDisconnectEvent/_itself_/disconnect002/TestDescription.java \ + vmTestbase/nsk/jdi/VMDisconnectEvent/_itself_/disconnect003/TestDescription.java \ + vmTestbase/nsk/jdi/VMStartEvent/thread/thread001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointEvent/object/object001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointEvent/field/field001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointEvent/valueCurrent/valuecur001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter002/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter003/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter004/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s002/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s003/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s004/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt002/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt003/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt004/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt005/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt006/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter002/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter003/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter004/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter005/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter006/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter007/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter008/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/field/field001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/field/field002/TestDescription.java \ + vmTestbase/nsk/jdi/AttachingConnector/attach/attach003/TestDescription.java \ + vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod003/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod010/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod014/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/newInstance/newinstance009/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/setValue/setvalue006/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/setValue/setvalue007/TestDescription.java \ + vmTestbase/nsk/jdi/Connector/_bounds_/bounds001/TestDescription.java \ + vmTestbase/nsk/jdi/Connector/toString/tostring001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x002/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x002/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc03x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x002/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x002/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc06x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc07x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc08x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x002/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x002/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/multithrd/tc01x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x002/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/singlethrd/tc02x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x002/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x003/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/singlethrd/tc04x001/TestDescription.java \ + vmTestbase/nsk/jdi/BScenarios/singlethrd/tc05x001/TestDescription.java \ + vmTestbase/nsk/jdi/Event/equals/equals001/TestDescription.java \ + vmTestbase/nsk/jdi/Event/hashCode/hashcode001/TestDescription.java \ + vmTestbase/nsk/jdi/EventQueue/hashCode/hashcode001/TestDescription.java \ + vmTestbase/nsk/jdi/EventRequest/disable/disable003/TestDescription.java \ + vmTestbase/nsk/jdi/EventRequest/hashCode/hashcode001/TestDescription.java \ + vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq003/TestDescription.java \ + vmTestbase/nsk/jdi/EventRequestManager/hashCode/hashcode001/TestDescription.java \ + vmTestbase/nsk/jdi/EventSet/resume/resume011/TestDescription.java \ + vmTestbase/nsk/jdi/EventSet/toString/tostring001/TestDescription.java \ + vmTestbase/nsk/jdi/EventSet/virtualMachine/virtualmachine001/TestDescription.java \ + vmTestbase/nsk/jdi/LocalVariable/toString/tostring001/TestDescription.java \ + vmTestbase/nsk/jdi/Method/_bounds_/bounds001/TestDescription.java \ + vmTestbase/nsk/jdi/Method/isObsolete/isobsolete003/TestDescription.java \ + vmTestbase/nsk/jdi/MethodEntryRequest/_bounds_/filters001/TestDescription.java \ + vmTestbase/nsk/jdi/MethodExitRequest/_bounds_/filters001/TestDescription.java \ + vmTestbase/nsk/jdi/Mirror/hashCode/hashcode001/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/_bounds_/bounds001/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/_bounds_/bounds002/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod002/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod003/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod004/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod005/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod007/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod008/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod009/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod012/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod013/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod014/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue002/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue003/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue004/TestDescription.java \ + vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue005/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/_bounds_/bounds001/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/_bounds_/bounds002/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/allFields/allfields005/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/allLineLocations/alllinelocations002/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/allLineLocations_ss/alllinelocations_ss002/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/allMethods/allmethods005/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/fields/fields005/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue004/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue005/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/getValues/getvalues002/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/getValues/getvalues003/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/locationsOfLine_i/locationsofline_i002/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/locationsOfLine_ssi/locationsofline_ssi002/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/methods/methods005/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/sourceName/sourcename004/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/sourceNames/sourcenames002/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/sourcePaths/sourcepaths002/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/visibleFields/visibfield005/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/visibleMethods/visibmethod006/TestDescription.java \ + vmTestbase/nsk/jdi/Scenarios/invokeMethod/popframes001/TestDescription.java \ + vmTestbase/nsk/jdi/Scenarios/invokeMethod/redefineclasses001/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/_bounds_/bounds002/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/getValue/getvalue003/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/getValues/getvalues003/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/hashCode/hashcode001/TestDescription.java \ + vmTestbase/nsk/jdi/StackFrame/setValue/setvalue005/setvalue005.java \ + vmTestbase/nsk/jdi/StackFrame/setValue/setvalue006/setvalue006.java \ + vmTestbase/nsk/jdi/StackFrame/toString/tostring001/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/_bounds_/filters001/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt003/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter001/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter002/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter003/TestDescription.java \ + vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter004/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadGroupReference/toString/tostring001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/frames_ii/frames_ii001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/ownedMonitors/ownedmonitors002/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes006/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes007/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/stop/stop002/TestDescription.java \ + vmTestbase/nsk/jdi/Type/hashCode/hashcode001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isPackagePrivate/ispackageprivate001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isPrivate/isprivate001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isProtected/isprotected001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isPublic/ispublic001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointEvent/_itself_/wevent001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/_bounds_/filters001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter001/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter002/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter003/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter004/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter005/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter006/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter007/TestDescription.java \ + vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter008/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canAddMethod/canaddmethod001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canGetSourceDebugExtension/cangetsde001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canPopFrames/canpopframes001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canRedefineClasses/canredefineclasses001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canRequestVMDeathEvent/canreqvmdev001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canUnrestrictedlyRedefineClasses/curc001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canUseInstanceFilters/canusefilters001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/getDefaultStratum/getdefaultstratum001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses002/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses003/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses004/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses005/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses006/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses007/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses008/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses009/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses010/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses011/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses012/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses013/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses014/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses015/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses016/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses020/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses022/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses024/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses026/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses027/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses028/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses029/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses030/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses032/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses034/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses035/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/setDefaultStratum/setdefaultstratum001/TestDescription.java \ + vmTestbase/nsk/jdi/VoidType/toString/tostring001/TestDescription.java \ + vmTestbase/nsk/jdi/VoidValue/equals/equals002/TestDescription.java \ + vmTestbase/nsk/jdi/VoidValue/toString/tostring001/TestDescription.java \ + vmTestbase/nsk/jdi/ConstantField/values001/TestDescription.java \ + vmTestbase/nsk/jdi/Accessible/isPackagePrivate/accipp002/TestDescription.java \ + vmTestbase/nsk/jdi/Accessible/isPrivate/isprivate002/TestDescription.java \ + vmTestbase/nsk/jdi/Accessible/isProtected/isprotected002/TestDescription.java \ + vmTestbase/nsk/jdi/Accessible/isPublic/ispublic002/TestDescription.java \ + vmTestbase/nsk/jdi/Accessible/isPublic/ispublic003/TestDescription.java \ + vmTestbase/nsk/jdi/Accessible/modifiers/modifiers002/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/allInterfaces/allinterfaces002/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/interfaces/interfaces002/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod015/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/isEnum/isenum001/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/setValue/setvalue008/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/subclasses/subclasses002/TestDescription.java \ + vmTestbase/nsk/jdi/ClassType/superclass/superclass002/TestDescription.java \ + vmTestbase/nsk/jdi/Field/isEnumConstant/isenumconstant001/TestDescription.java \ + vmTestbase/nsk/jdi/Field/type/type004/TestDescription.java \ + vmTestbase/nsk/jdi/Field/typeName/typename002/TestDescription.java \ + vmTestbase/nsk/jdi/LocalVariable/genericSignature/gensignature001/TestDescription.java \ + vmTestbase/nsk/jdi/Method/arguments/arguments003/TestDescription.java \ + vmTestbase/nsk/jdi/Method/argumentTypeNames/argumenttypenames003/TestDescription.java \ + vmTestbase/nsk/jdi/Method/isBridge/isbridge001/TestDescription.java \ + vmTestbase/nsk/jdi/Method/isVarArgs/isvarargs001/TestDescription.java \ + vmTestbase/nsk/jdi/PlugConnectors/AttachConnector/plugAttachConnect001/plugAttachConnect001.java \ + vmTestbase/nsk/jdi/PlugConnectors/AttachConnector/plugAttachConnect002/plugAttachConnect002.java \ + vmTestbase/nsk/jdi/PlugConnectors/AttachConnector/plugAttachConnect003/plugAttachConnect003.java \ + vmTestbase/nsk/jdi/PlugConnectors/LaunchConnector/plugLaunchConnect001/plugLaunchConnect001.java \ + vmTestbase/nsk/jdi/PlugConnectors/LaunchConnector/plugLaunchConnect002/plugLaunchConnect002.java \ + vmTestbase/nsk/jdi/PlugConnectors/LaunchConnector/plugLaunchConnect003/plugLaunchConnect003.java \ + vmTestbase/nsk/jdi/PlugConnectors/ListenConnector/plugListenConnect001/plugListenConnect001.java \ + vmTestbase/nsk/jdi/PlugConnectors/ListenConnector/plugListenConnect002/plugListenConnect002.java \ + vmTestbase/nsk/jdi/PlugConnectors/ListenConnector/plugListenConnect003/plugListenConnect003.java \ + vmTestbase/nsk/jdi/PlugConnectors/MultiConnectors/plugMultiConnect001/plugMultiConnect001.java \ + vmTestbase/nsk/jdi/PlugConnectors/MultiConnectors/plugMultiConnect002/plugMultiConnect002.java \ + vmTestbase/nsk/jdi/PlugConnectors/MultiConnectors/plugMultiConnect003/plugMultiConnect003.java \ + vmTestbase/nsk/jdi/PlugConnectors/MultiConnectors/plugMultiConnect004/plugMultiConnect004.java \ + vmTestbase/nsk/jdi/PlugConnectors/MultiConnectors/plugMultiConnect005/plugMultiConnect005.java \ + vmTestbase/nsk/jdi/PlugConnectors/MultiConnectors/plugMultiConnect006/plugMultiConnect006.java \ + vmTestbase/nsk/jdi/PlugConnectors/TransportService/transportService001/transportService001.java \ + vmTestbase/nsk/jdi/PlugConnectors/TransportService/transportService002/transportService002.java \ + vmTestbase/nsk/jdi/PlugConnectors/TransportService/transportService003/transportService003.java \ + vmTestbase/nsk/jdi/ReferenceType/allFields/allfields006/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/allMethods/allmethods006/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/classObject/classobj003/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/fields/fields006/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/genericSignature/genericSignature001/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/genericSignature/genericSignature002/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/isAbstract/isabstract003/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/isFinal/isfinal002/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/isInitialized/isinit003/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/methods/methods006/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/visibleFields/visibfield006/TestDescription.java \ + vmTestbase/nsk/jdi/ReferenceType/visibleMethods/visibmethod007/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/declaringType/decltype009/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/genericSignature/genericSignature001/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/genericSignature/genericSignature002/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isFinal/isfinal004/TestDescription.java \ + vmTestbase/nsk/jdi/TypeComponent/isStatic/isstatic004/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/canBeModified/canbemodified001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/createVirtualMachine/createVM001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/createVirtualMachine/createVM002/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/createVirtualMachine/createVM003/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/createVirtualMachine/createVM004/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachineManager/createVirtualMachine/createVM005/TestDescription.java \ + vmTestbase/nsk/jdi/VMCannotBeModifiedEx/_itself_/canntbemod001/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts001/instancecounts001.java \ + vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts002/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java \ + vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts004/instancecounts004.java \ + vmTestbase/nsk/jdi/ReferenceType/instances/instances001/instances001.java \ + vmTestbase/nsk/jdi/ReferenceType/instances/instances002/instances002.java \ + vmTestbase/nsk/jdi/ReferenceType/instances/instances005/instances005.java \ + vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects001/referringObjects001.java \ + vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects002/referringObjects002.java \ + vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects003/referringObjects003.java \ + vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects004/referringObjects004.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn003/forceEarlyReturn003.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn004/forceEarlyReturn004.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn005/forceEarlyReturn005.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn006/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn007/TestDescription.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn008/forceEarlyReturn008.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn009/forceEarlyReturn009.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn013/forceEarlyReturn013.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn014/forceEarlyReturn014.java \ + vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn015/forceEarlyReturn015.java \ + vmTestbase/nsk/jdi/ThreadReference/ownedMonitorsAndFrames/ownedMonitorsAndFrames001/ownedMonitorsAndFrames001.java \ + vmTestbase/nsk/jdi/ThreadReference/ownedMonitorsAndFrames/ownedMonitorsAndFrames002/ownedMonitorsAndFrames002.java \ + vmTestbase/nsk/jdi/ThreadReference/ownedMonitorsAndFrames/ownedMonitorsAndFrames003/ownedMonitorsAndFrames003.java \ + vmTestbase/nsk/jdi/ThreadReference/ownedMonitorsAndFrames/ownedMonitorsAndFrames004/ownedMonitorsAndFrames004.java \ + vmTestbase/nsk/jdi/ThreadReference/ownedMonitorsAndFrames/ownedMonitorsAndFrames005/ownedMonitorsAndFrames005.java \ + vmTestbase/nsk/jdi/ThreadReference/ownedMonitorsAndFrames/ownedMonitorsAndFrames008/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorContendedEnteredRequest/addClassExclusionFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorContendedEnteredRequest/addClassFilter_ClassName/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorContendedEnteredRequest/addClassFilter_ReferenceType/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorContendedEnteredRequest/addInstanceFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorContendedEnteredRequest/addThreadFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorContendedEnterRequest/addClassExclusionFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorContendedEnterRequest/addClassFilter_ClassName/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorContendedEnterRequest/addClassFilter_ReferenceType/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorContendedEnterRequest/addInstanceFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorContendedEnterRequest/addThreadFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorWaitRequest/addClassExclusionFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorWaitRequest/addClassFilter_ClassName/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorWaitRequest/addClassFilter_ReferenceType/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorWaitRequest/addInstanceFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorWaitRequest/addThreadFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorWaitedRequest/addClassExclusionFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorWaitedRequest/addClassFilter_ClassName/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorWaitedRequest/addClassFilter_ReferenceType/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorWaitedRequest/addInstanceFilter/TestDescription.java \ + vmTestbase/nsk/jdi/MonitorWaitedRequest/addThreadFilter/TestDescription.java \ + vmTestbase/nsk/jdi/stress/ClassPrepareEvents/ClassPrepareEvents001/ClassPrepareEvents001.java \ + vmTestbase/nsk/jdi/ClassPrepareRequest/addSourceNameFilter/addSourceNameFilter001/addSourceNameFilter001.java \ + vmTestbase/nsk/jdi/ClassPrepareRequest/addSourceNameFilter/addSourceNameFilter002/addSourceNameFilter002.java \ + vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001.java \ + vmTestbase/nsk/jdi/stress/serial/forceEarlyReturn001/TestDescription.java \ + vmTestbase/nsk/jdi/stress/serial/heapwalking001/TestDescription.java \ + vmTestbase/nsk/jdi/stress/serial/monitorEvents001/TestDescription.java \ + vmTestbase/nsk/jdi/stress/serial/ownedMonitorsAndFrames001/TestDescription.java \ + vmTestbase/nsk/jdi/stress/serial/mixed001/TestDescription.java \ + vmTestbase/nsk/jdi/stress/serial/forceEarlyReturn002/TestDescription.java \ + vmTestbase/nsk/jdi/stress/serial/monitorEvents002/TestDescription.java \ + vmTestbase/nsk/jdi/stress/serial/ownedMonitorsAndFrames002/TestDescription.java \ + vmTestbase/nsk/jdi/VirtualMachine/setDefaultStratum/setDefaultStratum002/setDefaultStratum002.java \ + vmTestbase/nsk/jdi/ReferenceType/allLineLocations_ss/allLineLocations_ss003/allLineLocations_ss003.java \ + vmTestbase/nsk/jdi/ReferenceType/allLineLocations_ss/allLineLocations_ss004/allLineLocations_ss004.java \ + vmTestbase/nsk/jdi/Method/allLineLocations_ss/allLineLocations_ss002/allLineLocations_ss002.java \ + vmTestbase/nsk/jdi/Method/allLineLocations_ss/allLineLocations_ss003/allLineLocations_ss003.java \ + vmTestbase/nsk/jdi/ReferenceType/locationsOfLine_ssi/locationsOfLine_ssi003/locationsOfLine_ssi003.java \ + vmTestbase/nsk/jdi/ReferenceType/locationsOfLine_ssi/locationsOfLine_ssi004/locationsOfLine_ssi004.java \ + vmTestbase/nsk/jdi/Method/locationsOfLine_ssi/locationsOfLine_ssi002/locationsOfLine_ssi002.java \ + vmTestbase/nsk/jdi/Method/locationsOfLine_ssi/locationsOfLine_ssi003/locationsOfLine_ssi003.java \ + vmTestbase/nsk/jdi/ReferenceType/sourceNames/sourceNames003/sourceNames003.java \ + vmTestbase/nsk/jdi/ReferenceType/sourcePaths/sourcePaths003/sourcePaths003.java \ + vmTestbase/nsk/jdi/ReferenceType/availableStrata/availableStrata002/availableStrata002.java \ + vmTestbase/nsk/jdi/ReferenceType/defaultStratum/defaultStratum002/defaultStratum002.java \ + vmTestbase/nsk/jdi/Location/lineNumber_s/lineNumber_s002/lineNumber_s002.java \ + vmTestbase/nsk/jdi/Location/sourceName_s/sourceName_s002/sourceName_s002.java \ + vmTestbase/nsk/jdi/Location/sourcePath_s/sourcePath_s002/sourcePath_s002.java \ + vmTestbase/nsk/jdi/AttachingConnector/attach/attach005/TestDescription.java \ + vmTestbase/nsk/jdi/AttachingConnector/attachnosuspend/attachnosuspend002/TestDescription.java \ + vmTestbase/nsk/jdi/AttachingConnector/attachnosuspend/attachnosuspend003/TestDescription.java \ + vmTestbase/nsk/jdi/MethodExitEvent/returnValue/returnValue001/returnValue001.java \ + vmTestbase/nsk/jdi/MethodExitEvent/returnValue/returnValue002/returnValue002.java \ + vmTestbase/nsk/jdi/MethodExitEvent/returnValue/returnValue003/returnValue003.java \ + vmTestbase/nsk/jdi/MethodExitEvent/returnValue/returnValue004/returnValue004.java \ + vmTestbase/nsk/jdi/StackFrame/getArgumentValues/getArgumentValues001/getArgumentValues001.java \ + vmTestbase/nsk/jdi/StackFrame/getArgumentValues/getArgumentValues002/getArgumentValues002.java \ + vmTestbase/nsk/jdi/StackFrame/getArgumentValues/getArgumentValues003/getArgumentValues003.java diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/AccessWatchpointEvent/_itself_/awevent001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/AccessWatchpointEvent/_itself_/awevent001.java new file mode 100644 index 00000000000..8ff5df69af0 --- /dev/null +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/AccessWatchpointEvent/_itself_/awevent001.java @@ -0,0 +1,425 @@ +/* + * Copyright (c) 2001, 2018, 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. + */ + +package nsk.jdi.AccessWatchpointEvent._itself_; + +import com.sun.jdi.Field; +import com.sun.jdi.Method; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.request.AccessWatchpointRequest; +import com.sun.jdi.request.BreakpointRequest; +import com.sun.jdi.request.EventRequestManager; +import com.sun.jdi.VMDisconnectedException; +import com.sun.jdi.VMMismatchException; +import com.sun.jdi.event.*; + +import java.util.Iterator; +import java.util.List; +import java.io.*; + +import nsk.share.*; +import nsk.share.jpda.*; +import nsk.share.jdi.*; + +/** + * The test checks that the JDI method + * com.sun.jdi.request.AccessWatchpointEvent.createAccessWatchpointRequest() + * properly creates new disabled watchpoints which watch accesses to + * the fields of different types. + * A debugger part of the test checks that: + *
Accessible works fine with
+ * the ArrayType sub-interface.
+ */
+public class accipp001 extends Log {
+ final static boolean MODE_VERBOSE = false;
+
+ /** The main class names of the debugger & debugee applications. */
+ private final static String
+ thisClassName = "nsk.jdi.Accessible.isPackagePrivate.accipp001",
+ debugeeName = thisClassName + "a";
+
+
+ static ArgumentHandler argsHandler;
+ private static Log logHandler;
+
+
+ /** Debugee's classes which status (private or public) is known. */
+ private final static String knownClasses[][] = {
+ {"boolean", "public"},
+ {"byte" , "public"},
+ {"char" , "public"},
+ {"double" , "public"},
+ {"float" , "public"},
+ {"int" , "public"},
+ {"long" , "public"},
+ {"short" , "public"},
+
+ {"java.lang.Boolean" , "public"},
+ {"java.lang.Byte" , "public"},
+ {"java.lang.Character", "public"},
+ {"java.lang.Double" , "public"},
+ {"java.lang.Float" , "public"},
+ {"java.lang.Integer" , "public"},
+ {"java.lang.Long" , "public"},
+ {"java.lang.Short" , "public"},
+ {"java.lang.String" , "public"},
+ {"java.lang.Object" , "public"},
+
+ {thisClassName+"a", "public" },
+ {thisClassName+"e", "package private"},
+
+ {debugeeName+"$U", "private" },
+ {debugeeName+"$V", "protected" },
+ {debugeeName+"$W", "public" },
+ {debugeeName+"$P", "package private"}
+ };
+
+ /**
+ * Re-call to run(args,out), and exit with
+ * either status 95 or 97 (JCK-like exit status).
+ */
+ public static void main (String args[]) {
+ int exitCode = run(args,System.out);
+ System.exit(exitCode + 95);
+ }
+
+ /**
+ * JCK-like entry point to the test: perform testing, and
+ * return exit code 0 (PASSED) or either 2 (FAILED).
+ */
+ public static int run (String args[], PrintStream out) {
+ return new accipp001().runThis(args,out); // incarnate Log
+ }
+
+ /**
+ * Non-static variant of the method run(args,out)
+ * can use Log features.
+ */
+ private int runThis (String argv[], PrintStream out) {
+
+ Debugee debugee;
+
+ argsHandler = new ArgumentHandler(argv);
+ logHandler = new Log(out, argsHandler);
+ Binder binder = new Binder(argsHandler, logHandler);
+
+
+ if (argsHandler.verbose()) {
+ debugee = binder.bindToDebugee(debugeeName + " -vbs");
+ } else {
+ debugee = binder.bindToDebugee(debugeeName);
+ }
+
+ IOPipe pipe = new IOPipe(debugee);
+
+
+ debugee.redirectStderr(out);
+ debugee.resume();
+
+ String line = pipe.readln();
+ if (!line.equals("ready")) {
+ logHandler.complain("# Cannot recognize debugee's signal: " + line);
+ return 2;
+ };
+
+// ReferenceType classes[] = debugee.classes();
+// for (int i=0; iisPrivate()
+ * of the JDI interface Accessible of com.sun.jdi package
+ * for ArrayType, ClassType, InterfaceType
+ */
+
+public class isPrivate001 extends Log {
+ static java.io.PrintStream out_stream;
+ static boolean verbose_mode = false;
+
+ /** The main class names of the debugger & debugee applications. */
+ private final static String
+ package_prefix = "nsk.jdi.Accessible.isPrivate.",
+// package_prefix = "", // for DEBUG without package
+ thisClassName = package_prefix + "isPrivate001",
+ debugeeName = thisClassName + "a";
+
+
+ static ArgumentHandler argsHandler;
+ private static Log logHandler;
+
+ /** Debugee's classes for check **/
+ private final static String classes_for_check[][] = {
+ {"boolean", "public", "primitive_type"},
+ {"byte" , "public", "primitive_type"},
+ {"char" , "public", "primitive_type"},
+ {"double" , "public", "primitive_type"},
+ {"float" , "public", "primitive_type"},
+ {"int" , "public", "primitive_type"},
+ {"long" , "public", "primitive_type"},
+
+ {"java.lang.Boolean" , "public", "reference_type"},
+ {"java.lang.Byte" , "public", "reference_type"},
+ {"java.lang.Character", "public", "reference_type"},
+ {"java.lang.Double" , "public", "reference_type"},
+ {"java.lang.Float" , "public", "reference_type"},
+ {"java.lang.Integer" , "public", "reference_type"},
+ {"java.lang.Long" , "public", "reference_type"},
+ {"java.lang.String" , "public", "reference_type"},
+ {"java.lang.Object" , "public", "reference_type"},
+
+ {thisClassName, "public", "reference_type" },
+ {thisClassName+"a", "public", "reference_type" },
+ {package_prefix + "pack_priv_cls", "package private", "reference_type"}, // class
+ {package_prefix + "pack_priv_interf", "package private", "reference_type"}, // interface
+
+ {debugeeName+"$s_interf", "private", "reference_type"}, // static interface
+
+ {debugeeName+"$U", "private", "reference_type" },
+ {debugeeName+"$V", "protected", "reference_type" },
+ {debugeeName+"$W", "public", "reference_type" },
+ {debugeeName+"$P", "package private", "reference_type"}
+ };
+
+
+ /**
+ * Re-call to run(args,out), and exit with
+ * either status 95 or 97 (JCK-like exit status).
+ */
+ public static void main (String argv[]) {
+ int exitCode = run(argv,System.out);
+ System.exit(exitCode + 95/*STATUS_TEMP*/);
+ }
+
+ /**
+ * JCK-like entry point to the test: perform testing, and
+ * return exit code 0 (PASSED) or either 2 (FAILED).
+ */
+ public static int run (String argv[], PrintStream out) {
+ out_stream = out;
+
+ int v_test_result = new isPrivate001().runThis(argv,out_stream);
+ if ( v_test_result == 2/*STATUS_FAILED*/ ) {
+ logHandler.display("\n==> nsk/jdi/Accessible/isPrivate/isPrivate001 test FAILED");
+ }
+ else {
+ logHandler.display("\n==> nsk/jdi/Accessible/isPrivate/isPrivate001 test PASSED");
+ }
+ return v_test_result;
+ }
+
+ private void print_log_on_verbose(String message) {
+ logHandler.display(message);
+ }
+
+ /**
+ * Non-static variant of the method run(args,out)
+ */
+ private int runThis (String argv[], PrintStream out) {
+
+ if ( out_stream == null ) {
+ out_stream = out;
+ }
+
+
+ Debugee debugee;
+
+ argsHandler = new ArgumentHandler(argv);
+ logHandler = new Log(out, argsHandler);
+ Binder binder = new Binder(argsHandler, logHandler);
+
+
+ if (argsHandler.verbose()) {
+ debugee = binder.bindToDebugee(debugeeName + " -vbs");
+ } else {
+ debugee = binder.bindToDebugee(debugeeName);
+ }
+
+ IOPipe pipe = new IOPipe(debugee);
+
+ logHandler.display("==> nsk/jdi/Accessible/isPrivate/isPrivate001 test LOG:");
+ logHandler.display("==> test checks the isPrivate() method of Accessible interface");
+ logHandler.display(" of the com.sun.jdi package for ArrayType, ClassType, InterfaceType\n");
+
+ debugee.redirectStderr(out);
+ print_log_on_verbose("--> isPrivate001: isPrivate001a debugee launched");
+ debugee.resume();
+
+ String line = pipe.readln();
+ if (line == null) {
+ logHandler.complain("##> isPrivate001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
+ return 2/*STATUS_FAILED*/;
+ }
+ if (!line.equals("ready")) {
+ logHandler.display("##> isPrivate001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
+ return 2/*STATUS_FAILED*/;
+ }
+ else {
+ print_log_on_verbose("--> isPrivate001: debugee's \"ready\" signal recieved!");
+ }
+
+ logHandler.display
+ ("--> isPrivate001: checking debugee's classes by Accessible.isPrivate() method...");
+ int all_classes_count = 0;
+ int class_not_found_errors = 0;
+ int isPrivate_method_errors = 0;
+
+
+ for (int i=0; iisProtected()
+ * of the JDI interface Accessible of com.sun.jdi package
+ * for ArrayType, ClassType, InterfaceType
+ */
+
+public class isProtected001 extends Log {
+ static java.io.PrintStream out_stream;
+ static boolean verbose_mode = false;
+
+ /** The main class names of the debugger & debugee applications. */
+ private final static String
+ package_prefix = "nsk.jdi.Accessible.isProtected.",
+// package_prefix = "", // for DEBUG without package
+ thisClassName = package_prefix + "isProtected001",
+ debugeeName = thisClassName + "a";
+
+
+ static ArgumentHandler argsHandler;
+ private static Log logHandler;
+
+
+ /** Debugee's classes for check **/
+ private final static String classes_for_check[][] = {
+ {"boolean", "public", "primitive_type"},
+ {"byte" , "public", "primitive_type"},
+ {"char" , "public", "primitive_type"},
+ {"double" , "public", "primitive_type"},
+ {"float" , "public", "primitive_type"},
+ {"int" , "public", "primitive_type"},
+ {"long" , "public", "primitive_type"},
+
+ {"java.lang.Boolean" , "public", "reference_type"},
+ {"java.lang.Byte" , "public", "reference_type"},
+ {"java.lang.Character", "public", "reference_type"},
+ {"java.lang.Double" , "public", "reference_type"},
+ {"java.lang.Float" , "public", "reference_type"},
+ {"java.lang.Integer" , "public", "reference_type"},
+ {"java.lang.Long" , "public", "reference_type"},
+ {"java.lang.String" , "public", "reference_type"},
+ {"java.lang.Object" , "public", "reference_type"},
+
+ {thisClassName, "public", "reference_type" },
+ {thisClassName+"a", "public", "reference_type" },
+ {package_prefix + "pack_priv_cls", "package private", "reference_type"}, // class
+ {package_prefix + "pack_priv_interf", "package private", "reference_type"}, // interface
+
+ {debugeeName+"$s_interf", "protected", "reference_type"}, // static interface
+
+ {debugeeName+"$U", "private", "reference_type" },
+ {debugeeName+"$V", "protected", "reference_type" },
+ {debugeeName+"$W", "public", "reference_type" },
+ {debugeeName+"$P", "package private", "reference_type"}
+ };
+
+ /**
+ * Re-call to run(args,out), and exit with
+ * either status 95 or 97 (JCK-like exit status).
+ */
+ public static void main (String argv[]) {
+ int exitCode = run(argv,System.out);
+ System.exit(exitCode + 95/*STATUS_TEMP*/);
+ }
+
+ /**
+ * JCK-like entry point to the test: perform testing, and
+ * return exit code 0 (PASSED) or either 2 (FAILED).
+ */
+ public static int run (String argv[], PrintStream out) {
+ out_stream = out;
+
+ int v_test_result = new isProtected001().runThis(argv,out_stream);
+ if ( v_test_result == 2/*STATUS_FAILED*/ ) {
+ logHandler.complain("\n==> nsk/jdi/Accessible/isProtected/isProtected001 test FAILED");
+ }
+ else {
+ logHandler.display("\n==> nsk/jdi/Accessible/isProtected/isProtected001 test PASSED");
+ }
+ return v_test_result;
+ }
+
+ private void print_log_on_verbose(String message) {
+ logHandler.display(message);
+ }
+
+ /**
+ * Non-static variant of the method run(args,out)
+ */
+ private int runThis (String argv[], PrintStream out) {
+
+ if ( out_stream == null ) {
+ out_stream = out;
+ }
+
+
+ Debugee debugee;
+
+ argsHandler = new ArgumentHandler(argv);
+ logHandler = new Log(out, argsHandler);
+ Binder binder = new Binder(argsHandler, logHandler);
+
+
+ if (argsHandler.verbose()) {
+ debugee = binder.bindToDebugee(debugeeName + " -vbs");
+ } else {
+ debugee = binder.bindToDebugee(debugeeName);
+ }
+
+ IOPipe pipe = new IOPipe(debugee);
+
+
+ logHandler.display("==> nsk/jdi/Accessible/isProtected/isProtected001 test LOG:");
+ logHandler.display("==> test checks the isProtected() method of Accessible interface");
+ logHandler.display(" of the com.sun.jdi package for ArrayType, ClassType, InterfaceType\n");
+
+
+ debugee.redirectStderr(out);
+ print_log_on_verbose("--> isProtected001: isProtected001a debugee launched");
+ debugee.resume();
+
+ String line = pipe.readln();
+ if (line == null) {
+ logHandler.complain("##> isProtected001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
+ return 2/*STATUS_FAILED*/;
+ }
+ if (!line.equals("ready")) {
+ logHandler.complain
+ ("##> isProtected001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
+ return 2/*STATUS_FAILED*/;
+ }
+ else {
+ print_log_on_verbose("--> isProtected001: debugee's \"ready\" signal recieved!");
+ }
+
+ logHandler.display
+ ("--> isProtected001: checking debugee's classes by Accessible.isProtected() method...");
+ int all_classes_count = 0;
+ int class_not_found_errors = 0;
+ int isProtected_method_errors = 0;
+ for (int i=0; iisPublic()
+ * of the JDI interface Accessible of com.sun.jdi package
+ * for ArrayType, ClassType, InterfaceType
+ */
+
+public class isPublic001 extends Log {
+ static java.io.PrintStream out_stream;
+ static boolean verbose_mode = false;
+
+ /** The main class names of the debugger & debugee applications. */
+ private final static String
+ package_prefix = "nsk.jdi.Accessible.isPublic.",
+// package_prefix = "", // for DEBUG without package
+ thisClassName = package_prefix + "isPublic001",
+ debugeeName = thisClassName + "a";
+
+
+ static ArgumentHandler argsHandler;
+ private static Log logHandler;
+
+
+ /** Debugee's classes for check **/
+ private final static String classes_for_check[][] = {
+ {"boolean", "public", "primitive_type"},
+ {"byte" , "public", "primitive_type"},
+ {"char" , "public", "primitive_type"},
+ {"double" , "public", "primitive_type"},
+ {"float" , "public", "primitive_type"},
+ {"int" , "public", "primitive_type"},
+ {"long" , "public", "primitive_type"},
+
+ {"java.lang.Boolean" , "public", "reference_type"},
+ {"java.lang.Byte" , "public", "reference_type"},
+ {"java.lang.Character", "public", "reference_type"},
+ {"java.lang.Double" , "public", "reference_type"},
+ {"java.lang.Float" , "public", "reference_type"},
+ {"java.lang.Integer" , "public", "reference_type"},
+ {"java.lang.Long" , "public", "reference_type"},
+ {"java.lang.String" , "public", "reference_type"},
+ {"java.lang.Object" , "public", "reference_type"},
+
+ {thisClassName, "public", "reference_type" },
+ {thisClassName+"a", "public", "reference_type" },
+ {package_prefix + "pack_priv_cls", "package private", "reference_type"}, // class
+ {package_prefix + "pack_priv_interf", "package private", "reference_type"}, // interface
+
+ {debugeeName+"$s_interf", "public", "reference_type"}, // interface
+
+ {debugeeName+"$U", "private", "reference_type" },
+ {debugeeName+"$V", "protected", "reference_type" },
+ {debugeeName+"$W", "public", "reference_type" },
+ {debugeeName+"$P", "package private", "reference_type"}
+ };
+
+ /**
+ * Re-call to run(args,out), and exit with
+ * either status 95 or 97 (JCK-like exit status).
+ */
+ public static void main (String argv[]) {
+ int exitCode = run(argv,System.out);
+ System.exit(exitCode + 95/*STATUS_TEMP*/);
+ }
+
+ /**
+ * JCK-like entry point to the test: perform testing, and
+ * return exit code 0 (PASSED) or either 2 (FAILED).
+ */
+ public static int run (String argv[], PrintStream out) {
+ out_stream = out;
+
+ int v_test_result = new isPublic001().runThis(argv,out_stream);
+ if ( v_test_result == 2/*STATUS_FAILED*/ ) {
+ logHandler.complain("\n==> nsk/jdi/Accessible/isPublic/isPublic001 test FAILED");
+ }
+ else {
+ logHandler.display("\n==> nsk/jdi/Accessible/isPublic/isPublic001 test PASSED");
+ }
+ return v_test_result;
+ }
+
+ private void print_log_on_verbose(String message) {
+ logHandler.display(message);
+ }
+
+ /**
+ * Non-static variant of the method run(args,out)
+ */
+ private int runThis (String argv[], PrintStream out) {
+ if ( out_stream == null ) {
+ out_stream = out;
+ }
+
+
+
+ Debugee debugee;
+
+ argsHandler = new ArgumentHandler(argv);
+ logHandler = new Log(out, argsHandler);
+ Binder binder = new Binder(argsHandler, logHandler);
+
+
+ if (argsHandler.verbose()) {
+ debugee = binder.bindToDebugee(debugeeName + " -vbs");
+ } else {
+ debugee = binder.bindToDebugee(debugeeName);
+ }
+
+ IOPipe pipe = new IOPipe(debugee);
+
+ logHandler.display("==> nsk/jdi/Accessible/isPublic/isPublic001 test LOG:");
+ logHandler.display("==> test checks the isPublic() method of Accessible interface");
+ logHandler.display(" of the com.sun.jdi package for ArrayType, ClassType, InterfaceType\n");
+
+
+ debugee.redirectStderr(out);
+ print_log_on_verbose("--> isPublic001: isPublic001a debugee launched");
+ debugee.resume();
+
+ String line = pipe.readln();
+ if (line == null) {
+ logHandler.complain
+ ("##> isPublic001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
+ return 2/*STATUS_FAILED*/;
+ }
+ if (!line.equals("ready")) {
+ logHandler.complain
+ ("##> isPublic001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
+ return 2/*STATUS_FAILED*/;
+ }
+ else {
+ print_log_on_verbose("--> isPublic001: debugee's \"ready\" signal recieved!");
+ }
+
+ logHandler.display
+ ("--> isPublic001: checking debugee's classes by Accessible.isPublic() method...");
+ int all_classes_count = 0;
+ int class_not_found_errors = 0;
+ int isPublic_method_errors = 0;
+ for (int i=0; imodifiers()
+ * of the JDI interface Accessible of com.sun.jdi package
+ * for ClassType, InterfaceType
+ */
+
+public class modifiers001 extends Log {
+ static java.io.PrintStream out_stream;
+ static boolean verbose_mode = false;
+
+ /** The main class names of the debugger & debugee applications. */
+ private final static String
+ package_prefix = "nsk.jdi.Accessible.modifiers.",
+// package_prefix = "", // for DEBUG without package
+ thisClassName = package_prefix + "modifiers001",
+ debugeeName = thisClassName + "a";
+
+
+ static ArgumentHandler argsHandler;
+ private static Log logHandler;
+
+
+ /** Debugee's classes for check **/
+ private final static String classes_for_check[][] = {
+
+ {"java.lang.Boolean" , "public, final", "class"},
+ {"java.lang.Byte" , "public, final", "class"},
+ {"java.lang.Character", "public, final", "class"},
+ {"java.lang.Double" , "public, final", "class"},
+ {"java.lang.Float" , "public, final", "class"},
+ {"java.lang.Integer" , "public, final", "class"},
+ {"java.lang.Long" , "public, final", "class"},
+ {"java.lang.String" , "public, final", "class"},
+ {"java.lang.Object" , "public ", "class"},
+
+ {thisClassName, "public", "class"},
+ {thisClassName+"a", "public", "class"},
+
+ {debugeeName+"$fin_s_cls", "final, static", "class"},
+ {debugeeName+"$abs_s_cls", "abstract, static", "class"},
+ {debugeeName+"$s_interf", "abstract, static, interface", "interface"},
+
+ {package_prefix + "simple_class", "run(args,out), and exit with
+ * either status 95 or 97 (JCK-like exit status).
+ */
+ public static void main (String argv[]) {
+ int exitCode = run(argv,System.out);
+ System.exit(exitCode + 95/*STATUS_TEMP*/);
+ }
+
+ /**
+ * JCK-like entry point to the test: perform testing, and
+ * return exit code 0 (PASSED) or either 2 (FAILED).
+ */
+ public static int run (String argv[], PrintStream out) {
+ out_stream = out;
+
+ int v_test_result = new modifiers001().runThis(argv,out_stream);
+ if ( v_test_result == 2/*STATUS_FAILED*/ ) {
+ logHandler.complain("\n==> nsk/jdi/Accessible/modifiers/modifiers001 test FAILED");
+ }
+ else {
+ logHandler.display("\n==> nsk/jdi/Accessible/modifiers/modifiers001 test PASSED");
+ }
+ return v_test_result;
+ }
+
+ private void print_log_on_verbose(String message) {
+ logHandler.display(message);
+ }
+
+ /**
+ * Non-static variant of the method run(args,out)
+ */
+ private int runThis (String argv[], PrintStream out) {
+ if ( out_stream == null ) {
+ out_stream = out;
+ }
+
+
+ Debugee debugee;
+
+ argsHandler = new ArgumentHandler(argv);
+ logHandler = new Log(out, argsHandler);
+ Binder binder = new Binder(argsHandler, logHandler);
+
+
+ if (argsHandler.verbose()) {
+ debugee = binder.bindToDebugee(debugeeName + " -vbs");
+ } else {
+ debugee = binder.bindToDebugee(debugeeName);
+ }
+
+ IOPipe pipe = new IOPipe(debugee);
+
+
+ logHandler.display("==> nsk/jdi/Accessible/modifiers/modifiers001 test LOG:");
+ logHandler.display("==> test checks the modifiers() method of Accessible interface");
+ logHandler.display(" of the com.sun.jdi package for ClassType, InterfaceType\n");
+
+
+ debugee.redirectStderr(out);
+ print_log_on_verbose("--> modifiers001: modifiers001a debugee launched");
+ debugee.resume();
+
+ String line = pipe.readln();
+ if (line == null) {
+ logHandler.complain
+ ("##> modifiers001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
+ return 2/*STATUS_FAILED*/;
+ }
+ if (!line.equals("ready")) {
+ logHandler.complain
+ ("##> modifiers001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
+ return 2/*STATUS_FAILED*/;
+ }
+ else {
+ print_log_on_verbose("--> modifiers001: debugee's \"ready\" signal recieved!");
+ }
+
+ logHandler.display
+ ("--> modifiers001: checking debugee's classes by Accessible.modifiers() method...\n");
+ int all_classes_count = 0;
+ int class_not_found_errors = 0;
+ int class_not_found_exceptions = 0;
+ int modifiers_method_errors = 0;
+// modifiers001a obj = new modifiers001a();
+ for (int i=0; icom.sun.jdi.connect.Connector.Argument.isValid() com.sun.jdi.connect.Connector.Argument.isValid() com.sun.jdi.connect.Connector.Argument.isValid() com.sun.jdi.connect.Connector.Argument.isValid() com.sun.jdi.connect.Connector.Argument.isValid() com.sun.jdi.connect.Connector.Argument.mustSpecify() com.sun.jdi.connect.Connector.Argument.setValue() com.sun.jdi.connect.Connector.Argument.setValue() Integer.MAX_VALUE + 1, -1, 0,
+ * 1, Integer.MAX_VALUE. 0 and length is -1,
+ * size of returned list has to be array length; 0 and length is 0,
+ * size if returned list has to be zero; IndexOutOfBoundsException is expected.com.sun.jdi.ArrayType.componentSignature() com.sun.jdi.ArrayType.componentSignature() com.sun.jdi.ArrayType.componentType() com.sun.jdi.ArrayType.componentTypeName() com.sun.jdi.ArrayType.componentTypeName() com.sun.jdi.ArrayType.newInstance() com.sun.jdi.ArrayType.newInstance() com.sun.jdi.ArrayType.newInstance() com.sun.jdi.ArrayType.newInstance() com.sun.jdi.SharedMemoryAttach connector.null value. In this case NullPointerExceptionIllegalConnectorArgumentsException is expected.performStep method.attach with wrong parameters.com.sun.jdi.SocketAttach connector.
+ */
+public class attachnosuspend001 {
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int JCK_STATUS_BASE = 95;
+ static final String DEBUGEE_CLASS =
+ "nsk.jdi.AttachingConnector.attachnosuspend.attachnosuspend001t";
+
+ private Log log;
+
+ private VirtualMachine vm;
+
+ private int attempts; // attempts to connect to the debugee VM
+ private int delay = 4000; // delay between connection attempts
+
+ IORedirector outRedirector;
+ IORedirector errRedirector;
+
+ public static void main (String argv[]) {
+ System.exit(run(argv,System.out) + JCK_STATUS_BASE);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+ return new attachnosuspend001().runIt(argv, out);
+ }
+
+ private int runIt(String argv[], PrintStream out) {
+ String port;
+ String listenPort;
+ Process proc;
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+
+// pass if "com.sun.jdi.SocketAttach" is not implemented
+// on this platform
+ if (argHandler.shouldPass("com.sun.jdi.SocketAttach"))
+ return PASSED;
+
+ log = new Log(out, argHandler);
+
+ String args[] = argHandler.getArguments();
+
+ // treat second positional argument as delay between connection attempts
+ try {
+ delay = Integer.parseInt(args[1]);
+ } catch (NumberFormatException e) {
+ log.complain("Incorrect test parameter: timeout value must be an integer");
+ return FAILED;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // ignore: default delay will be used if no second argument present
+ }
+ // calculate number of connection attempts to not exceed WAITTIME
+ long timeout = argHandler.getWaitTime() * 60 * 1000;
+ attempts = (int)(timeout / delay);
+
+ port = argHandler.getTransportPort();
+ listenPort = argHandler.getTransportPort();
+
+ String java = argHandler.getLaunchExecPath()
+ + " " + argHandler.getLaunchOptions();
+ String cmd = java +
+ " -Xdebug -Xnoagent -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" +
+ listenPort + " " + DEBUGEE_CLASS;
+
+ Binder binder = new Binder(argHandler, log);
+ log.display("command: " + cmd);
+ Debugee debugee = binder.startLocalDebugee(cmd);
+ debugee.redirectOutput(log);
+
+ if ((vm = attachTarget(argHandler.getTestHost(), port)) == null) {
+ log.complain("TEST: Unable to attach the debugee VM");
+ debugee.close();
+ return FAILED;
+ }
+
+ log.display("debugee VM: name=" + vm.name() + " JRE version=" +
+ vm.version() + "\n\tdescription=" + vm.description());
+
+ debugee.setupVM(vm);
+ //debugee.waitForVMInit(timeout);
+
+ //log.display("\nresuming debugee VM");
+ //debugee.resume();
+
+ log.display("\nwaiting for debugee VM exit");
+ int code = debugee.waitFor();
+ if (code != (JCK_STATUS_BASE+PASSED)) {
+ log.complain("Debugee VM has crashed: exit code=" +
+ code);
+ return FAILED;
+ }
+ log.display("debugee VM: exit code=" + code);
+ return PASSED;
+ }
+
+ private VirtualMachine attachTarget(String host, String port) {
+ Connector.Argument arg;
+
+ if (port == null) {
+ log.complain("TEST: port number is required!");
+ return null;
+ }
+
+ AttachingConnector connector =
+ (AttachingConnector) findConnector("com.sun.jdi.SocketAttach");
+
+ Mapethod_A and resumes debugee. It is expected
+ * the added line will be not actual after the redefining according to
+ * redefineClasses spec:
+ * "The redefined method will be used on new invokes. If resetting these
+ * frames is desired, use ThreadReference.popFrames() with
+ * Method.isObsolete()."
+ */
+
+public class tc01x001 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc01x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private int expectedEventCount = 5;
+
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc01x001 thisTest = new tc01x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ int eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+ debugee.setBreakpoint(debugeeClass,
+ tc01x001a.brkpMethodName,
+ tc01x001a.brkpLineNumber);
+
+ debugee.resume();
+ eventCount++;
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ display("redefining...");
+ redefineDebugee();
+
+ createMethodExitRequest(debugeeClass);
+ debugee.resume();
+ eventCount++;
+
+ } else if (event instanceof MethodExitEvent) {
+ display("\n event ===>>> " + event);
+ Method mthd = ((MethodExitEvent )event).method();
+ eventCount++;
+ display("exiting from \"" + mthd.name() + "\" method");
+ if (mthd.isObsolete()) {
+ Field fld = debugeeClass.fieldByName(tc01x001a.fieldToCheckName);
+ Value val = debugeeClass.getValue(fld);
+ if (((IntegerValue )val).value() == tc01x001a.CHANGED_VALUE) {
+ complain("Unexpected: new code is actual "
+ + "without resetting frames");
+ complain("Unexpected value of checked field: "
+ + val);
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("!!!Expected: new code is not actual "
+ + "without resetting frames!!!");
+ }
+ }
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Map extends com.sun.jdi.ReferenceType,byte[]> mapBytes;
+ boolean alreadyComplained = false;
+ mapBytes = mapClassToBytes(newClassFile);
+ try {
+ debugee.VM().redefineClasses(mapBytes);
+ } catch (Exception e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ }
+
+ private Map extends com.sun.jdi.ReferenceType,byte[]> mapClassToBytes(String fileName) {
+ display("class-file\t:" + fileName);
+ File fileToBeRedefined = new File(classDir + File.separator + fileName);
+ int fileToRedefineLength = (int )fileToBeRedefined.length();
+ byte[] arrayToRedefine = new byte[fileToRedefineLength];
+
+ FileInputStream inputFile;
+ try {
+ inputFile = new FileInputStream(fileToBeRedefined);
+ } catch (FileNotFoundException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+
+ try {
+ inputFile.read(arrayToRedefine);
+ inputFile.close();
+ } catch (IOException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ HashMaptc01x001a is deugee's part of the tc01x001.
+ */
+public class tc01x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 56;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc01x001a obj = new tc01x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() { // brkpLineNumber
+ method_B();
+ fieldToCheck = CHANGED_VALUE;
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x001a.java
new file mode 100644
index 00000000000..dee625307a6
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x001a.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc01x001a is deugee's part of the tc01x001.
+ */
+public class tc01x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 57;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc01x001a obj = new tc01x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B(); // brkpLineNumber
+// fieldToCheck = CHANGED_VALUE;
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x002.java
new file mode 100644
index 00000000000..48a6411dfe4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x002.java
@@ -0,0 +1,295 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 3 - Hot Swap
+ * Test case: TC1
+ * Description: After point of execution, same method
+ * Steps: 1.Set breakpoint at line 24 (call to b()
+ * from a())
+ * 2.Debug Main
+ * 3.Insert as next line after point of
+ * execution: System.err.println("foo");
+ * 4.Smart Swap
+ * 5.Resume
+ * X. Prints out "foo" after printing the
+ * numbers
+ * The description was drown up according to steps under JBuilder.
+ *
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 37th line (method method_A).
+ * After the breakpoint is reached, debugger redefines debugee adding
+ * a new line into method_A, pops current frame and resumes debugee.
+ * It is expected the new code will be actual after the redefining
+ *
+ * Step 5 of Borland's scenario is wrong due to redefineClasses spec says:
+ * "The redefined method will be used on new invokes. If resetting these
+ * frames is desired, use ThreadReference.popFrames() with
+ * Method.isObsolete()."
+ */
+
+public class tc01x002 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc01x002";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private int expectedEventCount = 5;
+
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc01x002 thisTest = new tc01x002();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ int eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+ debugee.setBreakpoint(debugeeClass,
+ tc01x002a.brkpMethodName,
+ tc01x002a.brkpLineNumber);
+
+ debugee.resume();
+ eventCount++;
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ display("redefining...");
+ redefineDebugee();
+ popFrames(((BreakpointEvent )event).thread());
+
+ createMethodExitRequest(debugeeClass);
+ debugee.resume();
+ eventCount++;
+
+ } else if (event instanceof MethodExitEvent) {
+ display("\n event ===>>> " + event);
+ Method mthd = ((MethodExitEvent )event).method();
+ eventCount++;
+ display("exiting from \"" + mthd.name() + "\" method");
+ if (mthd.name().compareTo(tc01x002a.brkpMethodName) == 0) {
+ Field fld = debugeeClass.fieldByName(tc01x002a.fieldToCheckName);
+ Value val = debugeeClass.getValue(fld);
+ if (((IntegerValue )val).value() != tc01x002a.CHANGED_VALUE) {
+ complain("Unexpected: new code is not actual "
+ + "after resetting frames");
+ complain("Unexpected value of checked field: "
+ + val);
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("!!!Expected: new code is actual "
+ + "after resetting frames!!!");
+ }
+ }
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Map extends com.sun.jdi.ReferenceType,byte[]> mapBytes;
+ boolean alreadyComplained = false;
+ mapBytes = mapClassToBytes(newClassFile);
+ try {
+ debugee.VM().redefineClasses(mapBytes);
+ } catch (Exception e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ }
+
+ private void popFrames(ThreadReference thread) {
+ try {
+ StackFrame frame = thread.frame(0);
+ thread.popFrames(frame);
+ } catch (IncompatibleThreadStateException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ }
+
+ private Map extends com.sun.jdi.ReferenceType,byte[]> mapClassToBytes(String fileName) {
+ display("class-file\t:" + fileName);
+ File fileToBeRedefined = new File(classDir + File.separator + fileName);
+ int fileToRedefineLength = (int )fileToBeRedefined.length();
+ byte[] arrayToRedefine = new byte[fileToRedefineLength];
+
+ FileInputStream inputFile;
+ try {
+ inputFile = new FileInputStream(fileToBeRedefined);
+ } catch (FileNotFoundException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+
+ try {
+ inputFile.read(arrayToRedefine);
+ inputFile.close();
+ } catch (IOException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ HashMaptc01x002a is deugee's part of the tc01x002.
+ */
+public class tc01x002a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 56;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc01x002a obj = new tc01x002a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() { // brkpLineNumber
+ method_B();
+ fieldToCheck = CHANGED_VALUE;
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x002a.java
new file mode 100644
index 00000000000..b52cdd45bd1
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc01x002a.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc01x002a is deugee's part of the tc01x002.
+ */
+public class tc01x002a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 57;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc01x002a obj = new tc01x002a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B(); // brkpLineNumber
+// fieldToCheck = CHANGED_VALUE;
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x001.java
new file mode 100644
index 00000000000..aba42b2ce3c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x001.java
@@ -0,0 +1,339 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 3 - Hot Swap
+ * Test case: TC2
+ * Description: Before point of execution, same method
+ * Steps: 1.Set breakpoint at line 24 (call to b()
+ * from a())
+ * 2.Debug Main
+ * 3.Insert as line before point of
+ * execution: System.err.println("foo");
+ * 4.Smart Swap
+ * 5.Set Smart PopFrame to beginging of
+ * method a()
+ * 6.Resume
+ * X. Prints out "foo" and hits breakpoint
+ * on line 24
+ * 7.Resume
+ * X. Prints numbers
+ * The description was drown up according to steps under JBuilder.
+ *
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 38th line (method method_A).
+ * After the breakpoint is reached, debugger: tc02x001a is deugee's part of the tc02x001.
+ */
+public class tc02x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 57;
+ public final static int checkLastLine = 57;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc02x001a obj = new tc02x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() { // brkpLineNumber // checkLastLine
+ method_B();
+ fieldToCheck = CHANGED_VALUE;
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x001a.java
new file mode 100644
index 00000000000..4c4c2288c5d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x001a.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc02x001a is deugee's part of the tc02x001.
+ */
+public class tc02x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 58;
+ public final static int checkLastLine = 58;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc02x001a obj = new tc02x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B(); // brkpLineNumber // checkLastLine
+// fieldToCheck = CHANGED_VALUE;
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x002.java
new file mode 100644
index 00000000000..eaeb7cbdc5d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x002.java
@@ -0,0 +1,347 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 3 - Hot Swap
+ * Test case: TC2
+ * Description: Before point of execution, same method
+ * Steps: 1.Set breakpoint at line 24 (call to b()
+ * from a())
+ * 2.Debug Main
+ * 3.Insert as line before point of
+ * execution: System.err.println("foo");
+ * 4.Smart Swap
+ * 5.Set Smart PopFrame to beginging of
+ * method a()
+ * 6.Resume
+ * X. Prints out "foo" and hits breakpoint
+ * on line 24
+ * 7.Resume
+ * X. Prints numbers
+ * The description was drown up according to steps under JBuilder.
+ *
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 38th line (method method_A).
+ * After the breakpoint is reached, debugger: tc02x002a is deugee's part of the tc02x002.
+ */
+public class tc02x002a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 57;
+ public final static int checkLastLine = 57;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc02x002a obj = new tc02x002a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() { // brkpLineNumber // checkLastLine
+ method_B();
+ fieldToCheck = CHANGED_VALUE;
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x002a.java
new file mode 100644
index 00000000000..06258a33ff4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc02x002a.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc02x002a is deugee's part of the tc02x002.
+ */
+public class tc02x002a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 58;
+ public final static int checkLastLine = 58;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc02x002a obj = new tc02x002a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B(); // brkpLineNumber // checkLastLine
+// fieldToCheck = CHANGED_VALUE;
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc03x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc03x001.java
new file mode 100644
index 00000000000..16644e8f6e2
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc03x001.java
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 3 - Hot Swap
+ * Test case: TC3
+ * Description: After point of execution, different method
+ * Steps: 1.Set breakpoint at line 24 (call from a()
+ * to b())
+ * 2.Debug Main
+ * 3.Insert as first line in b():
+ * System.err.println("foo");
+ * 4.Smart Swap
+ * 5.Resume
+ * X. Prints out "foo" before printing the
+ * numbers
+ * The description was drown up according to steps under JBuilder.
+ *
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 37th line (method method_A).
+ * After the breakpoint is reached, debugger redefines debugee adding
+ * first line into method_B and resumes debugee. It is expected the
+ * new code will be actual before calling method_C
+ */
+
+public class tc03x001 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc03x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private int expectedEventCount = 4;
+ private static final String methodNameToCheck = "method_C";
+
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc03x001 thisTest = new tc03x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ int eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+ debugee.setBreakpoint(debugeeClass,
+ tc03x001a.brkpMethodName,
+ tc03x001a.brkpLineNumber);
+
+ debugee.resume();
+ eventCount++;
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ display("redefining...");
+ redefineDebugee();
+
+ createMethodEntryRequest(debugeeClass);
+ debugee.resume();
+ eventCount++;
+
+ } else if (event instanceof MethodEntryEvent) {
+ display("\n event ===>>> " + event);
+ Method mthd = ((MethodEntryEvent )event).method();
+ eventCount++;
+ display("exiting from \"" + mthd.name() + "\" method");
+ if (mthd.name().compareTo(methodNameToCheck) == 0) {
+ Field fld = debugeeClass.fieldByName(tc03x001a.fieldToCheckName);
+ Value val = debugeeClass.getValue(fld);
+ if (((IntegerValue )val).value() == tc03x001a.CHANGED_VALUE) {
+ display("!!!Expected: new code is actual "
+ + "before calling " + methodNameToCheck
+ + "!!!");
+ } else {
+ complain("Unexpected: new code is not actual "
+ + "before calling " + methodNameToCheck);
+ complain("Unexpected value of checked field: "
+ + val);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ }
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Maptc03x001a is deugee's part of the tc03x001.
+ */
+public class tc03x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 56;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc03x001a obj = new tc03x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() { // brkpLineNumber
+ method_B();
+ }
+
+ public void method_B() {
+ fieldToCheck = CHANGED_VALUE;
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc03x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc03x001a.java
new file mode 100644
index 00000000000..42665742895
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc03x001a.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc03x001a is deugee's part of the tc03x001.
+ */
+public class tc03x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 57;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc03x001a obj = new tc03x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B(); // brkpLineNumber
+ }
+
+ public void method_B() {
+// fieldToCheck = CHANGED_VALUE;
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x001.java
new file mode 100644
index 00000000000..1cc69d32311
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x001.java
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 3 - Hot Swap
+ * Test case: TC4
+ * Description: Before point of execution, different method
+ * Steps: 1.Set breakpoint at line 30 (call to c()
+ * from b())
+ * 2.Debug Main
+ * 3.Insert as first line in a():
+ * System.err.println("foo");
+ * 4.Smart Swap
+ * 5.Set Smart PopFrame to beginging of
+ * method a()
+ * 6.Resume
+ * X. Prints out "foo" and hits breakpoint
+ * at line 30
+ * 7.Resume
+ * X. Print numbers
+ * The description was drown up according to steps under JBuilder.
+ *
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 43th line (method method_B).
+ * After the breakpoint is reached, debugger:
+ * - redefines debugee adding a new line into method_A,
+ * - pops frames at beginning of method_A
+ * and resumes debugee.
+ * It is expected the new code will be actual after the redefining and
+ * it doesn't hit breakpoint.
+ */
+
+public class tc04x001 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc04x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private int expectedEventCount = 5;
+ private int eventCount = 0;
+
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc04x001 thisTest = new tc04x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+ debugee.setBreakpoint(debugeeClass,
+ tc04x001a.brkpMethodName,
+ tc04x001a.brkpLineNumber);
+
+ debugee.resume();
+ eventCount++;
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ switch (eventCount) {
+ case 1:
+ display("redefining...");
+ redefineDebugee();
+ popFrames(((BreakpointEvent )event).thread());
+ createMethodExitRequest(debugeeClass);
+
+ break;
+
+ default:
+ complain("Unexpected breakpoint hitting");
+ exitStatus = Consts.TEST_FAILED;
+ }
+ eventCount++;
+ hitBreakpoint((BreakpointEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof MethodExitEvent) {
+ display("\n event ===>>> " + event);
+ hitMethodExit((MethodExitEvent)event);
+ eventCount++;
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Map extends com.sun.jdi.ReferenceType,byte[]> mapBytes;
+ boolean alreadyComplained = false;
+ mapBytes = mapClassToBytes(newClassFile);
+ try {
+ debugee.VM().redefineClasses(mapBytes);
+ } catch (Exception e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ }
+
+ private void popFrames(ThreadReference thread) {
+ display("\npop frames...");
+ try {
+ StackFrame frame = thread.frame(0);
+ Method mthd = frame.location().method();
+ do {
+ thread.popFrames(frame);
+ display(mthd.name() + " is resetted");
+ frame = thread.frame(0);
+ mthd = frame.location().method();
+ } while (mthd.isObsolete());
+ } catch (IncompatibleThreadStateException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ display("");
+ }
+
+ private Map extends com.sun.jdi.ReferenceType,byte[]> mapClassToBytes(String fileName) {
+ display("class-file\t:" + fileName);
+ File fileToBeRedefined = new File(classDir + File.separator + fileName);
+ int fileToRedefineLength = (int )fileToBeRedefined.length();
+ byte[] arrayToRedefine = new byte[fileToRedefineLength];
+
+ FileInputStream inputFile;
+ try {
+ inputFile = new FileInputStream(fileToBeRedefined);
+ } catch (FileNotFoundException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+
+ try {
+ inputFile.read(arrayToRedefine);
+ inputFile.close();
+ } catch (IOException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ HashMaptc04x001a is deugee's part of the tc04x001.
+ */
+public class tc04x001a {
+
+ public final static String brkpMethodName = "method_B";
+ public final static int brkpLineNumber = 62;
+ public final static int checkLastLine = 62;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc04x001a obj = new tc04x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ fieldToCheck = CHANGED_VALUE;
+ method_B();
+ }
+
+ public void method_B() { // brkpLineNumber // checkLastLine
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x001a.java
new file mode 100644
index 00000000000..8e4d16dffa6
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x001a.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc04x001a is deugee's part of the tc04x001.
+ */
+public class tc04x001a {
+
+ public final static String brkpMethodName = "method_B";
+ public final static int brkpLineNumber = 63;
+ public final static int checkLastLine = 63;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc04x001a obj = new tc04x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+// fieldToCheck = CHANGED_VALUE;
+ method_B();
+ }
+
+ public void method_B() {
+ method_C(); // checkLastLine // checkLastLine
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x002.java
new file mode 100644
index 00000000000..467af1742fe
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x002.java
@@ -0,0 +1,354 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 3 - Hot Swap
+ * Test case: TC4
+ * Description: Before point of execution, different method
+ * Steps: 1.Set breakpoint at line 30 (call to c()
+ * from b())
+ * 2.Debug Main
+ * 3.Insert as first line in a():
+ * System.err.println("foo");
+ * 4.Smart Swap
+ * 5.Set Smart PopFrame to beginging of
+ * method a()
+ * 6.Resume
+ * X. Prints out "foo" and hits breakpoint
+ * at line 30
+ * 7.Resume
+ * X. Print numbers
+ * The description was drown up according to steps under JBuilder.
+ *
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 43th line (method method_B).
+ * After the breakpoint is reached, debugger:
+ * - redefines debugee adding a new line into method_A,
+ * - pops frames at beginning of method_A
+ * - sets breakpoint at the 43th line again
+ * and resumes debugee.
+ * It is expected the new code will be actual after the redefining and
+ * it hits breakpoint.
+ */
+
+public class tc04x002 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc04x002";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private int expectedEventCount = 6;
+ private int eventCount = 0;
+
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc04x002 thisTest = new tc04x002();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+ debugee.setBreakpoint(debugeeClass,
+ tc04x002a.brkpMethodName,
+ tc04x002a.brkpLineNumber);
+
+ debugee.resume();
+ eventCount++;
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ switch (eventCount) {
+ case 1:
+ display("redefining...");
+ redefineDebugee();
+ popFrames(((BreakpointEvent )event).thread());
+
+ debugee.setBreakpoint(debugeeClass,
+ tc04x002a.brkpMethodName,
+ tc04x002a.brkpLineNumber);
+ break;
+
+ case 2:
+ display("!!!Expected second breakpoint event!!!");
+ createMethodExitRequest(debugeeClass);
+ break;
+
+ default:
+ complain("Unexpected breakpoint event");
+ exitStatus = Consts.TEST_FAILED;
+ }
+ eventCount++;
+ hitBreakpoint((BreakpointEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof MethodExitEvent) {
+ display("\n event ===>>> " + event);
+ hitMethodExit((MethodExitEvent)event);
+ eventCount++;
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Maptc04x002a is deugee's part of the tc04x002.
+ */
+public class tc04x002a {
+
+ public final static String brkpMethodName = "method_B";
+ public final static int brkpLineNumber = 62;
+ public final static int checkLastLine = 62;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc04x002a obj = new tc04x002a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ fieldToCheck = CHANGED_VALUE;
+ method_B();
+ }
+
+ public void method_B() { // brkpLineNumber // checkLastLine
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x002a.java
new file mode 100644
index 00000000000..13632df3ef9
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc04x002a.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc04x002a is deugee's part of the tc04x002.
+ */
+public class tc04x002a {
+
+ public final static String brkpMethodName = "method_B";
+ public final static int brkpLineNumber = 63;
+ public final static int checkLastLine = 63;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc04x002a obj = new tc04x002a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+// fieldToCheck = CHANGED_VALUE;
+ method_B();
+ }
+
+ public void method_B() {
+ method_C(); // brkpLineNumber // checkLastLine
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x001.java
new file mode 100644
index 00000000000..47a49b89bf4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x001.java
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: method_A).
+ * After the breakpoint is reached, debugger redefines debugee adding
+ * a new line into method_A, creates StepRequest and
+ * resumes debugee. When the location of the current StepEvent is
+ * in method_B, created StepRequest is disabled.
+ * Working of debugger and debugee is synchronized via IOPipe channel.
+ */
+
+public class tc05x001 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc05x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ public final static String PERFORM_SGL = "perform";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String testDir;
+
+ private static final String firstMethodName = "method_B";
+
+ private int eventCount;
+ private int expectedEventCount = 2;
+ private ClassType debugeeClass;
+ StepRequest stepRequest = null;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc05x001 thisTest = new tc05x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ testDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.resume();
+ debugee.quit();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ debugeeClass = (ClassType)debugee.classByName(debugeeName);
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ debugee.VM().suspend();
+
+ display("Tested class\t:" + debugeeClass.name());
+
+ BreakpointRequest brkp = debugee.setBreakpoint(debugeeClass,
+ tc05x001a.brkpMethodName,
+ tc05x001a.brkpLineNumber);
+ debugee.resume();
+ debugee.sendSignal(PERFORM_SGL);
+
+ BreakpointEvent brkpEvent = waitBreakpointEvent(brkp, waitTime);
+
+ display("\nredefining...");
+ redefineDebugee();
+
+ ThreadReference thread = brkpEvent.thread();
+
+ EventRequestManager evm = debugee.getEventRequestManager();
+
+ display("creating step request INTO...");
+ stepRequest = evm.createStepRequest(thread, StepRequest.STEP_LINE,
+ StepRequest.STEP_INTO);
+ stepRequest.addClassFilter(debugeeClass);
+ stepRequest.enable();
+ debugee.resume();
+
+ boolean cmp = false;
+ StepEvent stepEvent;
+ Event event;
+ for (int i = 0; i < 3; i++) {
+ // waiting the breakpoint event
+ display("waiting step event...");
+ try {
+ event = debugee.waitingEvent(stepRequest, waitTime);
+ } catch (Exception e) {
+ stepRequest.disable();
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ if (!(event instanceof StepEvent )) {
+ stepRequest.disable();
+ throw new Failure("StepEvent didn't arrive");
+ }
+ if (hitStep((StepEvent )event)) {
+ break;
+ }
+ debugee.resume();
+ }
+ evm.deleteEventRequest(stepRequest);
+ debugee.resume();
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Maptc05x001a is deugee's part of the tc05x001.
+ */
+public class tc05x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 69;
+ private static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println("ready");
+
+ String instr;
+ do {
+ instr = pipe.readln();
+ if (instr.equals("perform")) {
+ runIt();
+ } else if (instr.equals("quit")) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ private static void runIt() {
+ tc05x001a obj = new tc05x001a();
+ obj.method_A();
+ }
+
+ public void method_A() { // brkpLineNumber
+ method_B();
+ log.display("new line");
+// ^^^^^^^^^^^^^^^^^^^^^^^^ inserted line
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ log.display("method_C:: line 1");
+ log.display("method_C:: line 2");
+ log.display("method_C:: line 3");
+ log.display("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x001a.java
new file mode 100644
index 00000000000..ca4638fff32
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x001a.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc05x001a is deugee's part of the tc05x001.
+ */
+public class tc05x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 71;
+ private static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println("ready");
+
+ String instr;
+ do {
+ instr = pipe.readln();
+ if (instr.equals("perform")) {
+ runIt();
+ } else if (instr.equals("quit")) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ private static void runIt() {
+ tc05x001a obj = new tc05x001a();
+ obj.method_A();
+ }
+
+ public void method_A() {
+ method_B(); // brkpLineNumber
+// log.display("new line");
+// try inserting code here
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ log.display("method_C:: line 1");
+ log.display("method_C:: line 2");
+ log.display("method_C:: line 3");
+ log.display("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x002.java
new file mode 100644
index 00000000000..8523866c886
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x002.java
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: method_A).
+ * After the breakpoint is reached, debugger redefines debugee adding
+ * a new line into method_A, creates StepRequest and
+ * resumes debugee. When the location of the current StepEvent is
+ * in method_B, created StepRequest is disabled.
+ */
+
+public class tc05x002 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc05x002";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private static final String firstMethodName = "method_B";
+
+ private int eventCount;
+ private int expectedEventCount = 2;
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc05x002 thisTest = new tc05x002();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+ debugee.setBreakpoint(debugeeClass,
+ tc05x002a.brkpMethodName,
+ tc05x002a.brkpLineNumber);
+
+ debugee.resume();
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ hitBreakpoint((BreakpointEvent )event);
+ display("redefining...");
+ redefineDebugee();
+ createStepRequest(((LocatableEvent )event).thread());
+ debugee.resume();
+
+ } else if (event instanceof StepEvent) {
+ display("\n event ===>>> " + event);
+ hitStep((StepEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Maptc05x002a is deugee's part of the tc05x002.
+ */
+public class tc05x002a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 57;
+ public final static int checkLastLine = 57;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc05x002a obj = new tc05x002a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() { // brkpLineNumber // checkLastLine
+ method_B();
+ fieldToCheck = CHANGED_VALUE;
+// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inserted line
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x002a.java
new file mode 100644
index 00000000000..bb6c13feab7
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc05x002a.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc05x002a is deugee's part of the tc05x002.
+ */
+public class tc05x002a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 58;
+ public final static int checkLastLine = 58;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc05x002a obj = new tc05x002a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B(); // brkpLineNumber // checkLastLine
+// fieldToCheck = CHANGED_VALUE;
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc06x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc06x001.java
new file mode 100644
index 00000000000..8bb869b9ed7
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc06x001.java
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: method_A).
+ * After the breakpoint is reached, debugger redefines debugee adding
+ * a new line into method_A, pops frames,creates StepRequest
+ * and resumes debugee.
+ * When the location of the current StepEvent is in method_B,
+ * created StepRequest is disabled. The test checks up location of every
+ * step event and that new code becomes actual.
+ */
+
+public class tc06x001 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc06x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private static final String firstMethodName = "method_A";
+ private static final String lastMethodName = "method_B";
+
+ private int eventCount;
+ private int expectedEventCount = 4;
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc06x001 thisTest = new tc06x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+ debugee.setBreakpoint(debugeeClass,
+ tc06x001a.brkpMethodName,
+ tc06x001a.brkpLineNumber);
+
+ debugee.resume();
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ hitBreakpoint((BreakpointEvent )event);
+ display("redefining...");
+ redefineDebugee();
+ popFrames(((BreakpointEvent )event).thread());
+ createStepRequest(((LocatableEvent )event).thread());
+ debugee.resume();
+
+ } else if (event instanceof StepEvent) {
+ display("\n event ===>>> " + event);
+ hitStep((StepEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Maptc06x001a is deugee's part of the tc06x001.
+ */
+public class tc06x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 58;
+ public final static int checkLastLine = 58;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc06x001a obj = new tc06x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ fieldToCheck = CHANGED_VALUE; // brkpLineNumber // checkLastLine
+// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inserted line
+ method_B();
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc06x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc06x001a.java
new file mode 100644
index 00000000000..0b73833bd4d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc06x001a.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc06x001a is deugee's part of the tc06x001.
+ */
+public class tc06x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 59;
+ public final static int checkLastLine = 59;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc06x001a obj = new tc06x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+// fieldToCheck = CHANGED_VALUE;
+ method_B(); // brkpLineNumber // checkLastLine
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc07x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc07x001.java
new file mode 100644
index 00000000000..d8bfa5ab6b4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc07x001.java
@@ -0,0 +1,342 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: method method_A). After the breakpoint is reached,
+ * debugger redefines debugee inserting first line into method_B, creates
+ * StepRequest and resumes debugee. When the location of the
+ * current StepEvent is in method_C, created
+ * StepRequest is disabled.
+ * The test checks up location of every step event and that new code
+ * becomes actual.
+ */
+
+public class tc07x001 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc07x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private static final String firstMethodName = "method_B";
+ private static final String lastMethodName = "method_C";
+
+ private int eventCount;
+ private int expectedEventCount = 4;
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc07x001 thisTest = new tc07x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+ debugee.setBreakpoint(debugeeClass,
+ tc07x001a.brkpMethodName,
+ tc07x001a.brkpLineNumber);
+
+ debugee.resume();
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ hitBreakpoint((BreakpointEvent )event);
+ display("redefining...");
+ redefineDebugee();
+ createStepRequest(((LocatableEvent )event).thread());
+ debugee.resume();
+
+ } else if (event instanceof StepEvent) {
+ display("\n event ===>>> " + event);
+ hitStep((StepEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Map extends com.sun.jdi.ReferenceType,byte[]> mapBytes;
+ boolean alreadyComplained = false;
+ mapBytes = mapClassToBytes(newClassFile);
+ try {
+ debugee.VM().redefineClasses(mapBytes);
+ } catch (Exception e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ }
+
+ private Map extends com.sun.jdi.ReferenceType,byte[]> mapClassToBytes(String fileName) {
+ display("class-file\t:" + fileName);
+ File fileToBeRedefined = new File(classDir + File.separator + fileName);
+ int fileToRedefineLength = (int )fileToBeRedefined.length();
+ byte[] arrayToRedefine = new byte[fileToRedefineLength];
+
+ FileInputStream inputFile;
+ try {
+ inputFile = new FileInputStream(fileToBeRedefined);
+ } catch (FileNotFoundException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+
+ try {
+ inputFile.read(arrayToRedefine);
+ inputFile.close();
+ } catch (IOException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ HashMaptc07x001a is deugee's part of the tc07x001.
+ */
+public class tc07x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 57;
+ public final static int checkLastLine = 57;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc07x001a obj = new tc07x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() { // brkpLineNumber // checkLastLine
+ method_B();
+ }
+
+ public void method_B() {
+ fieldToCheck = CHANGED_VALUE;
+// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inserted line
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc07x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc07x001a.java
new file mode 100644
index 00000000000..9a5f1ca78be
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc07x001a.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc07x001a is deugee's part of the tc07x001.
+ */
+public class tc07x001a {
+
+ public final static String brkpMethodName = "method_A";
+ public final static int brkpLineNumber = 58;
+ public final static int checkLastLine = 58;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc07x001a obj = new tc07x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B(); // brkpLineNumber // checkLastLine
+ }
+
+ public void method_B() {
+// fieldToCheck = CHANGED_VALUE;
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc08x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc08x001.java
new file mode 100644
index 00000000000..9cbd96a4de2
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc08x001.java
@@ -0,0 +1,353 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: method_A).
+ * After the breakpoint is reached, debugger redefines debugee adding
+ * a new line into method_A, pops frame, creates StepRequest
+ * and resumes debugee. When the second StepEvent is reached, created
+ * StepRequest is disabled.
+ */
+
+public class tc08x001 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc08x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private static final String firstMethodName = "method_A";
+
+ private int eventCount;
+ private int expectedEventCount = 3;
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc08x001 thisTest = new tc08x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+ debugee.setBreakpoint(debugeeClass,
+ tc08x001a.brkpMethodName,
+ tc08x001a.brkpLineNumber);
+
+ debugee.resume();
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ hitBreakpoint((BreakpointEvent )event);
+ display("redefining...");
+ redefineDebugee();
+ popFrames(((BreakpointEvent )event).thread());
+ createStepRequest(((LocatableEvent )event).thread());
+ debugee.resume();
+
+ } else if (event instanceof StepEvent) {
+ display("\n event ===>>> " + event);
+ hitStep((StepEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Map extends com.sun.jdi.ReferenceType,byte[]> mapBytes;
+ boolean alreadyComplained = false;
+ mapBytes = mapClassToBytes(newClassFile);
+ try {
+ debugee.VM().redefineClasses(mapBytes);
+ } catch (Exception e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ }
+
+ private Map extends com.sun.jdi.ReferenceType,byte[]> mapClassToBytes(String fileName) {
+ display("class-file\t:" + fileName);
+ File fileToBeRedefined = new File(classDir + File.separator + fileName);
+ int fileToRedefineLength = (int )fileToBeRedefined.length();
+ byte[] arrayToRedefine = new byte[fileToRedefineLength];
+
+ FileInputStream inputFile;
+ try {
+ inputFile = new FileInputStream(fileToBeRedefined);
+ } catch (FileNotFoundException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+
+ try {
+ inputFile.read(arrayToRedefine);
+ inputFile.close();
+ } catch (IOException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ HashMaptc08x001a is deugee's part of the tc08x001.
+ */
+public class tc08x001a {
+
+ public final static String brkpMethodName = "method_B";
+ public final static int brkpLineNumber = 62;
+ public final static int checkLastLine = 62;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc08x001a obj = new tc08x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ fieldToCheck = CHANGED_VALUE;
+// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inserted line
+ method_B();
+ }
+ // brkpLineNumber // checkLastLine
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc08x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc08x001a.java
new file mode 100644
index 00000000000..285f0812a84
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc08x001a.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc08x001a is deugee's part of the tc08x001.
+ */
+public class tc08x001a {
+
+ public final static String brkpMethodName = "method_B";
+ public final static int brkpLineNumber = 63;
+ public final static int checkLastLine = 63;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc08x001a obj = new tc08x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+// fieldToCheck = CHANGED_VALUE;
+ method_B();
+ }
+
+ public void method_B() {
+ method_C(); // brkpLineNumber // checkLastLine
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x001.java
new file mode 100644
index 00000000000..283d50bcce4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x001.java
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: method_C).
+ * After the first breakpoint is reached, debugger redefines debugee
+ * deleting 48th line and resumes debugee. No breakpoints are
+ * expected anymore.
+ */
+
+public class tc09x001 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc09x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private int eventCount;
+ private int expectedEventCount = 1;
+ private ReferenceType debugeeClass;
+ private BreakpointRequest brkpRequest1 = null,
+ brkpRequest2 = null;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc09x001 thisTest = new tc09x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+
+ brkpRequest1 = debugee.setBreakpoint(debugeeClass,
+ tc09x001a.brkpMethodName,
+ tc09x001a.brkpLineNumber1);
+
+ brkpRequest2 = debugee.setBreakpoint(debugeeClass,
+ tc09x001a.brkpMethodName,
+ tc09x001a.brkpLineNumber2);
+
+ breakpointInfo(brkpRequest1);
+ breakpointInfo(brkpRequest2);
+
+ debugee.resume();
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ hitBreakpoint((BreakpointEvent )event);
+ if (eventCount == 1) {
+ display("redefining...");
+ redefineDebugee();
+ breakpointInfo(brkpRequest1);
+ breakpointInfo(brkpRequest2);
+ }
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Map extends com.sun.jdi.ReferenceType,byte[]> mapBytes;
+ boolean alreadyComplained = false;
+ mapBytes = mapClassToBytes(newClassFile);
+ try {
+ debugee.VM().redefineClasses(mapBytes);
+ } catch (Exception e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ }
+
+ private Map extends com.sun.jdi.ReferenceType,byte[]> mapClassToBytes(String fileName) {
+ display("class-file\t:" + fileName);
+ File fileToBeRedefined = new File(classDir + File.separator + fileName);
+ int fileToRedefineLength = (int )fileToBeRedefined.length();
+ byte[] arrayToRedefine = new byte[fileToRedefineLength];
+
+ FileInputStream inputFile;
+ try {
+ inputFile = new FileInputStream(fileToBeRedefined);
+ } catch (FileNotFoundException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+
+ try {
+ inputFile.read(arrayToRedefine);
+ inputFile.close();
+ } catch (IOException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ HashMaptc09x001a is deugee's part of the tc09x001.
+ */
+public class tc09x001a {
+
+ public final static String brkpMethodName = "method_C";
+ public final static int brkpLineNumber1 = 66;
+ public final static int brkpLineNumber2 = 69;
+ public final static int checkLastLine = 66;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc09x001a obj = new tc09x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B();
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() { // brkpLineNumber1 // checkLastLine
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4"); // brkpLineNumber2
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x001a.java
new file mode 100644
index 00000000000..9611a07a0cd
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x001a.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc09x001a is deugee's part of the tc09x001.
+ */
+public class tc09x001a {
+
+ public final static String brkpMethodName = "method_C";
+ public final static int brkpLineNumber1 = 67;
+ public final static int brkpLineNumber2 = 70;
+ public final static int checkLastLine = 67;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc09x001a obj = new tc09x001a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B();
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1"); // brkpLineNumber1 // checkLastLine
+ System.err.println("method_C:: line 2"); // this line will be removed
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4"); // brkpLineNumber2
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x002.java
new file mode 100644
index 00000000000..5c6308c4a69
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x002.java
@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: method_C).
+ * After the first breakpoint is reached, debugger redefines debugee
+ * deleting 48th line and attempts to set another breakpoint at 49th line.
+ * Because line number info is not available after redefining, it is
+ * expected IndexOutOfBoundsException will be thrown.
+ */
+
+public class tc09x002 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc09x002";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private int eventCount;
+ private int expectedEventCount = 1;
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc09x002 thisTest = new tc09x002();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ BreakpointRequest brkpRequest1, brkpRequest2;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+
+ brkpRequest1 = debugee.setBreakpoint(debugeeClass,
+ tc09x002a.brkpMethodName,
+ tc09x002a.brkpLineNumber1);
+
+ brkpRequest2 = debugee.setBreakpoint(debugeeClass,
+ tc09x002a.brkpMethodName,
+ tc09x002a.brkpLineNumber2);
+
+ breakpointInfo(brkpRequest1);
+ breakpointInfo(brkpRequest2);
+
+ debugee.resume();
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ hitBreakpoint((BreakpointEvent )event);
+
+ if (eventCount == 1) {
+ display("redefining...");
+ redefineDebugee();
+ Method method = null;
+ try {
+ method = ((BreakpointEvent )event).thread().frame(0).location().method();
+ } catch (IncompatibleThreadStateException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+
+ display("\nsetting breakpoint at the redefined method...");
+ try {
+ Location location = debugee.getLineLocation(method, tc09x002a.brkpLineNumber2);
+ if (location != null) {
+ brkpRequest2 = evm.createBreakpointRequest(location);
+ if (method.isObsolete()) {
+ complain("Locations of the redefined method "
+ + "should be not available: " + location);
+ complain("BreakpointRequest for not available location "
+ + "should be created: " + brkpRequest2);
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("No location found for unavailable line after class redefinition");
+ }
+ }
+ } catch (Exception e) {
+ display("Unspecified exception caught while setting breakpoint "
+ + "to unavailable line after class redefinition:\n\t" + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ }
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Map extends com.sun.jdi.ReferenceType,byte[]> mapBytes;
+ boolean alreadyComplained = false;
+ mapBytes = mapClassToBytes(newClassFile);
+ try {
+ debugee.VM().redefineClasses(mapBytes);
+ } catch (Exception e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ }
+
+ private Map extends com.sun.jdi.ReferenceType,byte[]> mapClassToBytes(String fileName) {
+ display("class-file\t:" + fileName);
+ File fileToBeRedefined = new File(classDir + File.separator + fileName);
+ int fileToRedefineLength = (int )fileToBeRedefined.length();
+ byte[] arrayToRedefine = new byte[fileToRedefineLength];
+
+ FileInputStream inputFile;
+ try {
+ inputFile = new FileInputStream(fileToBeRedefined);
+ } catch (FileNotFoundException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+
+ try {
+ inputFile.read(arrayToRedefine);
+ inputFile.close();
+ } catch (IOException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ HashMaptc09x002a is deugee's part of the tc09x002.
+ */
+public class tc09x002a {
+
+ public final static String brkpMethodName = "method_C";
+ public final static int brkpLineNumber1 = 66;
+ public final static int brkpLineNumber2 = 69;
+ public final static int checkLastLine = 66;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc09x002a obj = new tc09x002a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B();
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() { // brkpLineNumber1 // checkLastLine
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4"); // brkpLineNumber2
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x002a.java
new file mode 100644
index 00000000000..3da0e071f83
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc09x002a.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc09x002a is deugee's part of the tc09x002.
+ */
+public class tc09x002a {
+
+ public final static String brkpMethodName = "method_C";
+ public final static int brkpLineNumber1 = 67;
+ public final static int brkpLineNumber2 = 70;
+ public final static int checkLastLine = 67;
+ public final static String fieldToCheckName = "fieldToCheck";
+ public final static int INITIAL_VALUE = 0;
+ public final static int CHANGED_VALUE = 1;
+
+ private static Log log;
+ private static int fieldToCheck = INITIAL_VALUE;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc09x002a obj = new tc09x002a();
+ obj.method_A();
+
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B();
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1"); // brkpLineNumber1 // checkLastLine
+ System.err.println("method_C:: line 2"); // this line will be removed
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4"); // brkpLineNumber2
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001.java
new file mode 100644
index 00000000000..43f4b07719d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001.java
@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: main).
+ * After the breakpoint is reached, debugger redefines debugee changing
+ * type of local variable and resumes debugee.
+ * After resuming debugee sends value of the variable via IOPipe channel,
+ * debugger reads this value and compares it with expected the one.
+ * In this case expected value is the value before redefinition.
+ */
+
+public class tc10x001 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc10x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private int eventCount;
+ private int expectedEventCount = 1;
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc10x001 thisTest = new tc10x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+ debugee.createIOPipe();
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ BreakpointRequest brkpRequest;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+
+ brkpRequest = debugee.setBreakpoint(debugeeClass,
+ tc10x001a.brkpMethodName,
+ tc10x001a.brkpLineNumber);
+ debugee.resume();
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ hitBreakpoint((BreakpointEvent )event);
+
+ display("redefining...");
+ redefineDebugee();
+
+ Receiver recv = new Receiver();
+ recv.start();
+
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Map extends com.sun.jdi.ReferenceType,byte[]> mapBytes;
+ boolean alreadyComplained = false;
+ mapBytes = mapClassToBytes(newClassFile);
+ try {
+ debugee.VM().redefineClasses(mapBytes);
+ } catch (Exception e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ }
+
+ private Map extends com.sun.jdi.ReferenceType,byte[]> mapClassToBytes(String fileName) {
+ display("class-file\t:" + fileName);
+ File fileToBeRedefined = new File(classDir + File.separator + fileName);
+ int fileToRedefineLength = (int )fileToBeRedefined.length();
+ byte[] arrayToRedefine = new byte[fileToRedefineLength];
+
+ FileInputStream inputFile;
+ try {
+ inputFile = new FileInputStream(fileToBeRedefined);
+ } catch (FileNotFoundException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+
+ try {
+ inputFile.read(arrayToRedefine);
+ inputFile.close();
+ } catch (IOException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ HashMaptc10x001a is deugee's part of the tc10x001.
+ */
+public class tc10x001a {
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 54;
+ public final static int checkLastLine = 54;
+ public final static int INITIAL_INT_VALUE = 42;
+ public final static boolean INITIAL_BOOL_VALUE = true;
+
+ private static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+
+ boolean i = INITIAL_BOOL_VALUE;
+// ^^^^^^^ has been changed
+ tc10x001a obj = new tc10x001a();
+ obj.method_A();
+ // brkpLineNumber // checkLastLine
+ System.err.println("i = " + i);
+ pipe.println("@" + i);
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B();
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001a.java
new file mode 100644
index 00000000000..e5fe3e4e571
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001a.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc10x001a is deugee's part of the tc10x001.
+ */
+public class tc10x001a {
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 55;
+ public final static int checkLastLine = 55;
+ public final static int INITIAL_INT_VALUE = 42;
+ public final static boolean INITIAL_BOOL_VALUE = true;
+
+ private static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+
+ int i = INITIAL_INT_VALUE;
+// ^^^ will be changed
+ tc10x001a obj = new tc10x001a();
+ obj.method_A();
+
+ System.err.println("i = " + i); // brkpLineNumber // checkLastLine
+ pipe.println("@" + i);
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public void method_A() {
+ method_B();
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x002.java
new file mode 100644
index 00000000000..252d8404fe1
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x002.java
@@ -0,0 +1,347 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: runIt).
+ * Note: the runIt method was added into the test, to allow invoking
+ * ThreadReference.popFrame(). Current frame can not be reset because of
+ * there is no previous frame.
+ * After the breakpoint is reached, debugger redefines debugee changing type of
+ * local variable, pops current frame, sets a new breakpoint at 37th line and
+ * resumes debugee.
+ * When the second breakpoint hits, debugger requests value of the local
+ * variable i and compares got value with expected value.
+ * In this case expected value is the new value after redefinition.
+ */
+
+public class tc10x002 {
+
+ public final static String UNEXPECTED_STRING = "***Unexpected exception ";
+
+ private final static String prefix = "nsk.jdi.BScenarios.hotswap.";
+ private final static String debuggerName = prefix + "tc10x002";
+ private final static String debugeeName = debuggerName + "a";
+
+ private final static String newClassFile = "newclass" + File.separator
+ + debugeeName.replace('.',File.separatorChar)
+ + ".class";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static String classDir;
+
+ private int eventCount;
+ private int expectedEventCount = 2;
+ private ReferenceType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc10x002 thisTest = new tc10x002();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ classDir = argv[0];
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+ debugee.createIOPipe();
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ if (!debugee.VM().canRedefineClasses()) {
+ display("\n>>>canRedefineClasses() is false<<< test canceled.\n");
+ return;
+ }
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ BreakpointRequest brkpRequest;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ eventCount = 0;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ ClassPrepareRequest req = evm.createClassPrepareRequest();
+ req.addClassFilter(debugeeName);
+ req.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display("\n event ===>>> " + event);
+
+ if (event instanceof ClassPrepareEvent) {
+ display("\n event ===>>> " + event);
+ debugeeClass = ((ClassPrepareEvent )event).referenceType();
+ display("Tested class\t:" + debugeeClass.name());
+
+ brkpRequest = debugee.setBreakpoint(debugeeClass,
+ tc10x002a.brkpMethodName,
+ tc10x002a.brkpLineNumber1);
+ debugee.resume();
+
+ } else if (event instanceof BreakpointEvent) {
+ display("\n event ===>>> " + event);
+ BreakpointEvent brkpEvent = (BreakpointEvent )event;
+
+ switch (eventCount) {
+ case 0:
+ hitBreakpoint(brkpEvent, tc10x002a.checkLastLine1);
+ display("redefining...");
+ redefineDebugee();
+
+ popFrames(brkpEvent.thread());
+
+ brkpRequest = debugee.setBreakpoint(debugeeClass,
+ tc10x002a.brkpMethodName,
+ tc10x002a.brkpLineNumber2);
+ break;
+ case 1:
+ Value val = null;
+ hitBreakpoint(brkpEvent, tc10x002a.checkLastLine2);
+ try {
+ StackFrame frame = brkpEvent.thread().frame(0);
+ LocalVariable var = frame.visibleVariableByName("i");
+ display("local variable:\t" + var);
+ val = frame.getValue(var);
+ } catch (Exception e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ display("\nValue of local variable:\t" + val);
+ if (((PrimitiveValue)val).booleanValue() ==
+ tc10x002a.INITIAL_BOOL_VALUE) {
+ display("!!!Expected value of local variable!!!\n");
+ } else {
+ complain("Unexpected value of local variable.\n");
+ exitStatus = Consts.TEST_FAILED;
+ }
+ break;
+ }
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount != expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void redefineDebugee() {
+ Map extends com.sun.jdi.ReferenceType,byte[]> mapBytes;
+ boolean alreadyComplained = false;
+ mapBytes = mapClassToBytes(newClassFile);
+ try {
+ debugee.VM().redefineClasses(mapBytes);
+ } catch (Exception e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ }
+
+ private Map extends com.sun.jdi.ReferenceType,byte[]> mapClassToBytes(String fileName) {
+ display("class-file\t:" + fileName);
+ File fileToBeRedefined = new File(classDir + File.separator + fileName);
+ int fileToRedefineLength = (int )fileToBeRedefined.length();
+ byte[] arrayToRedefine = new byte[fileToRedefineLength];
+
+ FileInputStream inputFile;
+ try {
+ inputFile = new FileInputStream(fileToBeRedefined);
+ } catch (FileNotFoundException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+
+ try {
+ inputFile.read(arrayToRedefine);
+ inputFile.close();
+ } catch (IOException e) {
+ throw new Failure(UNEXPECTED_STRING + e);
+ }
+ HashMaptc10x002a is deugee's part of the tc10x002.
+ */
+public class tc10x002a {
+
+ public final static String brkpMethodName = "runIt";
+ public final static int brkpLineNumber1 = 60;
+ public final static int brkpLineNumber2 = 57;
+ public final static int checkLastLine1 = 60;
+ public final static int checkLastLine2 = 57;
+ public final static int INITIAL_INT_VALUE = 42;
+ public final static boolean INITIAL_BOOL_VALUE = true;
+
+ private static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ runIt();
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void runIt() {
+ boolean i = INITIAL_BOOL_VALUE;
+// ^^^^^^^ ^^^^^^^^^^^^^^^^^^ redefined line // brkpLineNumber2 // checkLastLine2
+ tc10x002a obj = new tc10x002a();
+ obj.method_A();
+ // brkpLineNumber1 // checkLastLine1
+ System.err.println("i = " + i);
+ }
+
+ public void method_A() {
+ method_B();
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x002a.java
new file mode 100644
index 00000000000..0827661474f
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x002a.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.hotswap;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc10x002a is deugee's part of the tc10x002.
+ */
+public class tc10x002a {
+
+ public final static String brkpMethodName = "runIt";
+ public final static int brkpLineNumber1 = 61;
+ public final static int brkpLineNumber2 = 58;
+ public final static int checkLastLine1 = 61;
+ public final static int checkLastLine2 = 58;
+ public final static int INITIAL_INT_VALUE = 42;
+ public final static boolean INITIAL_BOOL_VALUE = true;
+
+ private static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ runIt();
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void runIt() {
+ int i = INITIAL_INT_VALUE;
+// ^^^ ^^^^^^^^^^^^^^^^^ will be redefined
+ tc10x002a obj = new tc10x002a(); // brkpLineNumber2 // checkLastLine2
+ obj.method_A();
+
+ System.err.println("i = " + i); // brkpLineNumber1 // checkLastLine1
+ }
+
+ public void method_A() {
+ method_B();
+ }
+
+ public void method_B() {
+ method_C();
+ }
+
+ public void method_C() {
+ System.err.println("method_C:: line 1");
+ System.err.println("method_C:: line 2");
+ System.err.println("method_C:: line 3");
+ System.err.println("method_C:: line 4");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc01x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc01x001.java
new file mode 100644
index 00000000000..ec720d829ed
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc01x001.java
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: tc01x001a is deugee's part of the tc01x001.
+ */
+public class tc01x001a {
+
+ public final static String brkpMethodName = "bar";
+ public final static int brkpLineNumber = 89;
+
+ public final static int checkBrkpLine = 89;
+ public final static int checkStepLine = 90;
+ public final static int threadCount = 3;
+ private static Log log;
+
+ Thready [] thrds = new Thready [threadCount];
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc01x001.SGL_READY);
+
+ tc01x001a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ if (instr.equals(tc01x001.SGL_PERFORM)) {
+ obj = new tc01x001a();
+ } else if (instr.equals(tc01x001.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ try {
+ for (int i = 0; i < obj.thrds.length; i++ ) {
+ obj.thrds[i].join();
+ }
+ } catch (InterruptedException e) {
+ }
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ tc01x001a() {
+ for (int i = 0; i < thrds.length; i++ ) {
+ thrds[i] = new Thready("Thread-" + (i+1));
+ thrds[i].start();
+ }
+ }
+
+ public static void foo(String caller) {
+ log.display(caller + "::foo is called");
+ }
+
+ public static void bar(String caller) {
+ log.display(caller + "::bar is called"); // brkpLineNumber // checkBrkpLine
+ log.display(caller + "::bar_step"); // checkStepLine
+ }
+
+ static class Thready extends Thread {
+ Thready(String name) {
+ super(name);
+ }
+
+ public void run() {
+ tc01x001a.foo(getName());
+ tc01x001a.bar(getName());
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001.java
new file mode 100644
index 00000000000..6803fd51629
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001.java
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc02x001aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc02x001 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.multithrd.";
+ private final static String debuggerName = prefix + "tc02x001";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String testedClassName = debugeeName + "Class1";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static int brkpEventCount = 0;
+
+ private ClassType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc02x001 thisTest = new tc02x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.resume();
+ debugee.quit();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ debugeeClass = (ClassType)debugee.classByName(debugeeName);
+ display("Tested class\t:" + debugeeClass.name());
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ EventRequestManager evm = debugee.getEventRequestManager();
+ MethodEntryRequest mthdReq = evm.createMethodEntryRequest();
+ mthdReq.addClassFilter(testedClassName);
+ mthdReq.enable();
+
+ debugee.resume();
+ debugee.sendSignal(SGL_PERFORM);
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+
+ if (event instanceof MethodEntryEvent) {
+ hitClassBreakpoint((MethodEntryEvent )event);
+ display(" event ===>>> " + (brkpEventCount+1) + " MethodEntryEvent arrived");
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ exit = exit || (brkpEventCount == tc02x001a.threadCount);
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (brkpEventCount < tc02x001a.threadCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + tc02x001a.threadCount
+ + " MethodBreakpoint events, but "
+ + brkpEventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void hitClassBreakpoint(MethodEntryEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ if (event.location().lineNumber() == tc02x001a.checkClassBrkpLine) {
+ display("ClassBreakpoint stops on the expected line "
+ + event.location().lineNumber() + " in method "
+ + event.method().name());
+ } else {
+ complain("ClassBreakpoint stops on line " + event.location().lineNumber()
+ + " in method " + event.method().name()
+ + ", expected line number is "
+ + tc02x001a.checkClassBrkpLine);
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("");
+
+ brkpEventCount++;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001/TestDescription.java
new file mode 100644
index 00000000000..ff0175af276
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001/TestDescription.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/multithrd/tc02x001.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC2
+ * Description: Class breakpoint
+ * Steps: 1.Add class breakpoint: singlethread.Class1
+ * 2.Debug Main
+ * X. Stops on line 13 in Class1.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc02x001aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ * The test synchronizes debugger and debugee executing via IOPipe channel.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * There are a doublness of the "class breakpoint" understanding.
+ * Here is that JBuilder help says:
+ * 1. "A class breakpoint causes the debugger to stop when any method
+ * from the specified class is called or when the specified class
+ * is instantiated."
+ * So, a class breakpoint is MethodEntryRequest with filtering
+ * the specified class.
+ * 2. "A class breakpoint causes the debugger to stop at the location
+ * when the specified class is loaded or when any method from the
+ * specified class is called."
+ * In this case, a class breakpoint is MethodEntryRequest and
+ * ClassPrepareRequest with filtering the specified class.
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.multithrd.tc02x001
+ * nsk.jdi.BScenarios.multithrd.tc02x001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.multithrd.tc02x001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001a.java
new file mode 100644
index 00000000000..91a8cb1f08b
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001a.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc02x001a is deugee's part of the tc02x001.
+ */
+public class tc02x001a {
+
+ public final static int threadCount = 3;
+ static Log log;
+
+ public final static int checkClassBrkpLine = 93;
+ Thready [] thrds = new Thready [threadCount];
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc02x001.SGL_READY);
+
+ tc02x001a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ log.display("instr \"" + instr + "\"");
+ if (instr.equals(tc02x001.SGL_PERFORM)) {
+ obj = new tc02x001a();
+ } else if (instr.equals(tc02x001.SGL_QUIT)) {
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ try {
+ for (int i = 0; i < obj.thrds.length; i++ ) {
+ obj.thrds[i].join();
+ }
+ } catch (InterruptedException e) {
+ }
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ tc02x001a() {
+ for (int i = 0; i < thrds.length; i++ ) {
+ thrds[i] = new Thready("Thread-" + (i+1));
+ thrds[i].start();
+ }
+ }
+
+ static class Thready extends Thread {
+ Thready(String name) {
+ super(name);
+ }
+
+ public void run() {
+ log.display(getName() + ":: creating tc02x001aClass1");
+ new tc02x001aClass1(getName());
+ }
+ }
+}
+
+class tc02x001aClass1 {
+ public tc02x001aClass1(String thrdName) { // checkClassBrkpLine
+ tc02x001a.log.display("tc02x001aClass1::constructor is called from"
+ + thrdName);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002.java
new file mode 100644
index 00000000000..960ef8ed2ca
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002.java
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 80th or 82th lines, that are static initializer and
+ * constructor of tc02x001aClass1 class. Every thread must generate
+ * MethodEntryEvent.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc02x002 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_LOAD = "load";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.multithrd.";
+ private final static String debuggerName = prefix + "tc02x002";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String testedClassName = debugeeName + "Class1";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static int eventCount = 0;
+
+ private EventRequestManager evm = null;
+ private MethodEntryRequest mthdReq = null;
+ private volatile boolean exit = false;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+ tc02x002 thisTest = new tc02x002();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+ IOPipe pipe = debugee.createIOPipe();
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+ evm = debugee.getEventRequestManager();
+
+ ClassPrepareRequest crq = evm.createClassPrepareRequest();
+ crq.addClassFilter(testedClassName);
+ crq.enable();
+
+ // event handling thread
+ Thread eventHandler = new Thread() {
+ public void run() {
+ EventQueue eventQueue = debugee.VM().eventQueue();
+ EventSet eventSet = null;
+ while (!exit) {
+ try {
+ eventSet = eventQueue.remove(1000);
+ } catch (InterruptedException e) {
+ new Failure("Event handling thread interrupted:\n\t" + e);
+ }
+ if (eventSet == null) {
+ continue;
+ }
+ EventIterator eventIterator = eventSet.eventIterator();
+ while (eventIterator.hasNext()) {
+ Event event = eventIterator.nextEvent();
+
+ if (event instanceof ClassPrepareEvent) {
+ display(" event ===>>> " + event);
+ mthdReq = evm.createMethodEntryRequest();
+ mthdReq.addClassFilter(testedClassName);
+ mthdReq.enable();
+ debugee.resume();
+
+ } else if (event instanceof MethodEntryEvent) {
+ display(" event ===>>> " + (eventCount+1) + " MethodEntryEvent arrived");
+ hitEvent((MethodEntryEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } else {
+ throw new Failure("Unexpected event:\n\t" + event);
+ } // if
+ exit = exit || (eventCount >= tc02x002a.threadCount + 1);
+ } // while
+ } // while
+ } // run()
+ }; // eventHadler
+
+ display("Starting handling event");
+ eventHandler.start();
+
+ debugee.resume();
+ debugee.receiveExpectedSignal(SGL_READY);
+
+ display("\nTEST BEGINS");
+ display("===========");
+ debugee.sendSignal(SGL_LOAD);
+
+ display("Waiting for all events received");
+ try {
+ eventHandler.join(waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("Main thread interrupted while waiting for eventHandler:\n\t"
+ + e);
+ } finally {
+ crq.disable();
+ mthdReq.disable();
+ exit = true;
+ if (eventHandler.isAlive()) {
+ display("Interrupting event handling thread");
+ eventHandler.interrupt();
+ }
+ }
+
+ if (eventCount < tc02x002a.threadCount) {
+ complain("expecting " + tc02x002a.threadCount
+ + " breakpoint events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ debugee.sendSignal(SGL_QUIT);
+ }
+
+ private void hitEvent(MethodEntryEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+ if (event.location().lineNumber() == tc02x002a.checkClassBrkpLine1 ||
+ event.location().lineNumber() == tc02x002a.checkClassBrkpLine2) {
+ display("MethodEntryEvent occurs on the expected line "
+ + event.location().lineNumber() + " in method "
+ + event.method().name());
+ } else {
+ complain("MethodEntryEvent occurs on line " + event.location().lineNumber()
+ + " in method " + event.method().name()
+ + ", expected line numbers are "
+ + tc02x002a.checkClassBrkpLine1 + ", "
+ + tc02x002a.checkClassBrkpLine2);
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("");
+
+ eventCount++;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002/TestDescription.java
new file mode 100644
index 00000000000..800fa741b18
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002/TestDescription.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/multithrd/tc02x002.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC2
+ * Description: Class breakpoint
+ * Steps: 1.Add class breakpoint: singlethread.Class1
+ * 2.Debug Main
+ * X. Stops on line 13 in Class1.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates ClassPrepareRequest
+ * MethodEntryRequest with adding filter via class name.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 80th or 82th lines, that are static initializer
+ * and constructor of tc02x001aClass1 class. Every thread must generate
+ * MethodEntryEvent.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * There are a doublness of the "class breakpoint" understanding.
+ * Here is that JBuilder help says:
+ * 1. "A class breakpoint causes the debugger to stop when any method
+ * from the specified class is called or when the specified class
+ * is instantiated."
+ * So, a class breakpoint is MethodEntryRequest with filtering
+ * the specified class.
+ * 2. "A class breakpoint causes the debugger to stop at the location
+ * when the specified class is loaded or when any method from the
+ * specified class is called."
+ * In this case, a class breakpoint is MethodEntryRequest and
+ * ClassPrepareRequest with filtering the specified class.
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ * Test fixed according to test bug:
+ * 4804095 TEST_BUG: potential race condition with loading classes in JDI tests
+ * - launching debuggee by prepareDebugee() replaced with bindToDebugee()
+ * to exclude first IOPipe communication
+ * - making ClassPrepareRequest moved to begin (right after debuggee started)
+ * - making MethodEntryRequest moved to handling ClassPrepareEvent
+ * - handling events moved to a separate thread
+ * - removed extra IOPipe communication points to make algorithm more clear
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.multithrd.tc02x002
+ * nsk.jdi.BScenarios.multithrd.tc02x002a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.multithrd.tc02x002
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002a.java
new file mode 100644
index 00000000000..a0bf559387d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002a.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc02x002a is deugee's part of the tc02x002.
+ */
+public class tc02x002a {
+
+ public final static int threadCount = 3;
+ static Log log;
+
+ public final static int checkClassBrkpLine1 = 96;
+ public final static int checkClassBrkpLine2 = 98;
+ Thready [] thrds = new Thready [threadCount];
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc02x002.SGL_READY);
+
+ tc02x002a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ if (instr.equals(tc02x002.SGL_LOAD)) {
+ tc02x002aClass1.loadThis = true;
+ obj = new tc02x002a();
+ } else if (instr.equals(tc02x002.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ try {
+ for (int i = 0; i < obj.thrds.length; i++ ) {
+ obj.thrds[i].join();
+ }
+ } catch (InterruptedException e) {
+ }
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ tc02x002a() {
+ for (int i = 0; i < thrds.length; i++ ) {
+ thrds[i] = new Thready("Thread-" + (i+1));
+ thrds[i].start();
+ }
+ }
+
+ static class Thready extends Thread {
+ Thready(String name) {
+ super(name);
+ }
+
+ public void run() {
+ log.display(getName() + ":: creating tc02x002aClass1");
+ new tc02x002aClass1(getName());
+ }
+ }
+}
+
+class tc02x002aClass1 {
+
+ static boolean loadThis = false; // checkClassBrkpLine1
+
+ public tc02x002aClass1(String thrdName) { // checkClassBrkpLine2
+ tc02x002a.log.display("tc02x002aClass1::constructor is called from"
+ + thrdName);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003.java
new file mode 100644
index 00000000000..4fd48e21ff0
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003.java
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 80th or 82th lines, that are static initializer and
+ * constructor of tc02x001aClass1 class. Every thread must generate
+ * MethodEntryEvent.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc02x003 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_LOAD = "load";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.multithrd.";
+ private final static String debuggerName = prefix + "tc02x003";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String testedClassName = debugeeName + "Class1";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static int eventCount = 0;
+
+ private EventRequestManager evm = null;
+ private MethodEntryRequest mthdReq = null;
+ private volatile boolean exit = false;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+ tc02x003 thisTest = new tc02x003();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+ IOPipe pipe = debugee.createIOPipe();
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+ evm = debugee.getEventRequestManager();
+
+ ClassPrepareRequest crq = evm.createClassPrepareRequest();
+ crq.addClassFilter(testedClassName);
+ crq.enable();
+
+ // event handling thread
+ Thread eventHandler = new Thread() {
+ public void run() {
+ EventQueue eventQueue = debugee.VM().eventQueue();
+ EventSet eventSet = null;
+ while (!exit) {
+ try {
+ eventSet = eventQueue.remove(1000);
+ } catch (InterruptedException e) {
+ new Failure("Event handling thread interrupted:\n\t" + e);
+ }
+ if (eventSet == null) {
+ continue;
+ }
+ EventIterator eventIterator = eventSet.eventIterator();
+ while (eventIterator.hasNext()) {
+ Event event = eventIterator.nextEvent();
+
+ if (event instanceof ClassPrepareEvent) {
+ display(" event ===>>> " + event);
+ ClassPrepareEvent clsEvent = (ClassPrepareEvent )event;
+ hitEvent(clsEvent);
+
+ mthdReq = evm.createMethodEntryRequest();
+ ReferenceType testedClass = clsEvent.referenceType();;
+ mthdReq.addClassFilter(testedClass);
+ mthdReq.enable();
+
+ debugee.resume();
+
+ } else if (event instanceof MethodEntryEvent) {
+ display(" event ===>>> " + event);
+ hitEvent((MethodEntryEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } else {
+ throw new Failure("Unexpected event:\n\t" + event);
+ } // if
+ exit = exit || (eventCount >= tc02x003a.threadCount + 2);
+ } // while
+ } // while
+ } // run()
+ }; // eventHadler
+
+ display("Starting handling event");
+ eventHandler.start();
+
+ debugee.resume();
+ debugee.receiveExpectedSignal(SGL_READY);
+
+ display("\nTEST BEGINS");
+ display("===========");
+ debugee.sendSignal(SGL_LOAD);
+
+ display("Waiting for all events received");
+ try {
+ eventHandler.join(waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("Main thread interrupted while waiting for eventHandler:\n\t"
+ + e);
+ } finally {
+ crq.disable();
+ mthdReq.disable();
+ exit = true;
+ if (eventHandler.isAlive()) {
+ display("Interrupting event handling thread");
+ eventHandler.interrupt();
+ }
+ }
+
+ if (eventCount < tc02x003a.threadCount) {
+ complain("expecting " + tc02x003a.threadCount
+ + " MethodBreakpoint events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ debugee.sendSignal(SGL_QUIT);
+ }
+
+ private void hitEvent(MethodEntryEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ if (event.location().lineNumber() == tc02x003a.checkClassBrkpLine1 ||
+ event.location().lineNumber() == tc02x003a.checkClassBrkpLine2) {
+ display("MethodEntryEvent occurs on the expected line "
+ + event.location().lineNumber() + " in method "
+ + event.method().name());
+ } else {
+ complain("MethodEntryEventOccurs on line " + event.location().lineNumber()
+ + " in method " + event.method().name()
+ + ", expected line numbers are "
+ + tc02x003a.checkClassBrkpLine1 + ", "
+ + tc02x003a.checkClassBrkpLine2);
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("");
+
+ eventCount++;
+ }
+
+ private void hitEvent(ClassPrepareEvent event) {
+ display("ClassPrepareEvent occursn");
+ eventCount++;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003/TestDescription.java
new file mode 100644
index 00000000000..226c0c2130d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003/TestDescription.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/multithrd/tc02x003.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC2
+ * Description: Class breakpoint
+ * Steps: 1.Add class breakpoint: singlethread.Class1
+ * 2.Debug Main
+ * X. Stops on line 13 in Class1.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates ClassPrepareRequest
+ * MethodEntryRequest with adding filter via reference type.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 80th or 82th lines, that are static initializer
+ * and constructor of tc02x001aClass1 class. Every thread must generate
+ * MethodEntryEvent.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * There are a doublness of the "class breakpoint" understanding.
+ * Here is that JBuilder help says:
+ * 1. "A class breakpoint causes the debugger to stop when any method
+ * from the specified class is called or when the specified class
+ * is instantiated."
+ * So, a class breakpoint is MethodEntryRequest with filtering
+ * the specified class.
+ * 2. "A class breakpoint causes the debugger to stop at the location
+ * when the specified class is loaded or when any method from the
+ * specified class is called."
+ * In this case, a class breakpoint is MethodEntryRequest and
+ * ClassPrepareRequest with filtering the specified class.
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ * Test fixed according to test bug:
+ * 4804095 TEST_BUG: potential race condition with loading classes in JDI tests
+ * - launching debuggee by prepareDebugee() replaced with bindToDebugee()
+ * to exclude first IOPipe communication
+ * - making ClassPrepareRequest moved to begin (right after debuggee started)
+ * - making MethodEntryRequest moved to handling ClassPrepareEvent
+ * - handling events moved to a separate thread
+ * - removed extra IOPipe communication points to make algorithm more clear
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.multithrd.tc02x003
+ * nsk.jdi.BScenarios.multithrd.tc02x003a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.multithrd.tc02x003
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003a.java
new file mode 100644
index 00000000000..2f4957d1fa4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003a.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc02x003a is deugee's part of the tc02x003.
+ */
+public class tc02x003a {
+
+ public final static int threadCount = 3;
+ static Log log;
+
+ public final static int checkClassBrkpLine1 = 96;
+ public final static int checkClassBrkpLine2 = 98;
+ Thready [] thrds = new Thready [threadCount];
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc02x003.SGL_READY);
+
+ tc02x003a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ if (instr.equals(tc02x003.SGL_LOAD)) {
+ tc02x003aClass1.loadThis = true;
+ obj = new tc02x003a();
+ } else if (instr.equals(tc02x003.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ try {
+ for (int i = 0; i < obj.thrds.length; i++ ) {
+ obj.thrds[i].join();
+ }
+ } catch (InterruptedException e) {
+ }
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ tc02x003a() {
+ for (int i = 0; i < thrds.length; i++ ) {
+ thrds[i] = new Thready("Thread-" + (i+1));
+ thrds[i].start();
+ }
+ }
+
+ static class Thready extends Thread {
+ Thready(String name) {
+ super(name);
+ }
+
+ public void run() {
+ log.display(getName() + ":: creating tc02x003aClass1");
+ new tc02x003aClass1(getName());
+ }
+ }
+}
+
+class tc02x003aClass1 {
+
+ static boolean loadThis = false; // checkClassBrkpLine1
+
+ public tc02x003aClass1(String thrdName) { // checkClassBrkpLine2
+ tc02x003a.log.display("tc02x003aClass1::constructor is called from"
+ + thrdName);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004.java
new file mode 100644
index 00000000000..9806d30f4da
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc02x004aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc02x004 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.multithrd.";
+ private final static String debuggerName = prefix + "tc02x004";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String testedClassName = debugeeName + "Class1";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static int brkpEventCount = 0;
+ MethodEntryRequest mthdReq;
+ EventRequestManager evm;
+
+ private ClassType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc02x004 thisTest = new tc02x004();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+ debugee.redirectStderr(log.getOutStream());
+ thisTest.evm = debugee.getEventRequestManager();
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ thisTest.evm.deleteEventRequest(thisTest.mthdReq);
+ } finally {
+ debugee.resume();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ display("\nTEST BEGINS");
+ display("===========");
+ debugee.resume();
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ mthdReq = evm.createMethodEntryRequest();
+ mthdReq.addClassFilter(testedClassName);
+ mthdReq.enable();
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+
+ if (event instanceof MethodEntryEvent) {
+ display(" event ===>>> " + (brkpEventCount+1) + " MethodEntryEvent arrived");
+ hitClassBreakpoint((MethodEntryEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ exit = exit || (brkpEventCount == tc02x004a.threadCount);
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ exitStatus = Consts.TEST_FAILED;
+ }
+ if (brkpEventCount < tc02x004a.threadCount) {
+ complain("expecting " + tc02x004a.threadCount
+ + " breakpoint events, but "
+ + brkpEventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void hitClassBreakpoint(MethodEntryEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ display("thread:\t" + event.thread().name());
+ try {
+ display("source:\t" + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("method:\t" + event.location().method().name());
+ display("line:\t" + event.location().lineNumber());
+ if (event.location().lineNumber() == tc02x004a.checkClassBrkpLine) {
+ display("ClassBreakpoint stops on the expected line "
+ + event.location().lineNumber() + " in method "
+ + event.method().name());
+ } else {
+ complain("ClassBreakpoint stops on line " + event.location().lineNumber()
+ + " in method " + event.method().name()
+ + ", expected line number is "
+ + tc02x004a.checkClassBrkpLine);
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("");
+
+ brkpEventCount++;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004/TestDescription.java
new file mode 100644
index 00000000000..b72c30c7952
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004/TestDescription.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/multithrd/tc02x004.
+ * VM Testbase keywords: [quick, jpda, jdi, quarantine]
+ * VM Testbase comments: JDK-4751860
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC2
+ * Description: Class breakpoint
+ * Steps: 1.Add class breakpoint: singlethread.Class1
+ * 2.Debug Main
+ * X. Stops on line 13 in Class1.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 59th line, that is constructor of tc02x004aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ * The test looks like tc002x001 except that synchronizing debugger and
+ * debugee is performed without IOPipe channel.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * There are a doublness of the "class breakpoint" understanding.
+ * Here is that JBuilder help says:
+ * 1. "A class breakpoint causes the debugger to stop when any method
+ * from the specified class is called or when the specified class
+ * is instantiated."
+ * So, a class breakpoint is MethodEntryRequest with filtering
+ * the specified class.
+ * 2. "A class breakpoint causes the debugger to stop at the location
+ * when the specified class is loaded or when any method from the
+ * specified class is called."
+ * In this case, a class breakpoint is MethodEntryRequest and
+ * ClassPrepareRequest with filtering the specified class.
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.multithrd.tc02x004
+ * nsk.jdi.BScenarios.multithrd.tc02x004a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.multithrd.tc02x004
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004a.java
new file mode 100644
index 00000000000..f41aed76609
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004a.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc02x004a is deugee's part of the tc02x004.
+ */
+public class tc02x004a {
+
+ public final static int threadCount = 3;
+ static Log log;
+
+ public final static int checkClassBrkpLine = 79;
+ Thready [] thrds = new Thready [threadCount];
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+
+ tc02x004a obj = new tc02x004a();
+
+ try {
+ for (int i = 0; i < obj.thrds.length; i++ ) {
+ obj.thrds[i].join();
+ }
+ } catch (InterruptedException e) {
+ }
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ tc02x004a() {
+ for (int i = 0; i < thrds.length; i++ ) {
+ thrds[i] = new Thready("Thread-" + (i+1));
+ thrds[i].start();
+ }
+ }
+
+ static class Thready extends Thread {
+ Thready(String name) {
+ super(name);
+ }
+
+ public void run() {
+ log.display(getName() + ":: creating tc02x004aClass1");
+ new tc02x004aClass1(getName());
+ }
+ }
+}
+
+class tc02x004aClass1 {
+ public tc02x004aClass1(String thrdName) { // checkClassBrkpLine
+ tc02x004a.log.display("tc02x004aClass1::constructor is called from"
+ + thrdName);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001.java
new file mode 100644
index 00000000000..986f5549ad2
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001.java
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC3
+ * Description: Exception breakpoint
+ * Steps: 1.Set caught exception breakpoint on class
+ * javax.sound.midi.MidiUnavailableException
+ * 2.Debug Main
+ * X. Stops on line 42 in Main.java
+ *
+ * When the test is starting debugee, debugger creates ExceptionRequest.
+ * After ExceptionEvent arrived, debugger checks line number of one's
+ * location. It should be 74th line, that is throwing tc03x001aException.
+ * Every thread must generate ExceptionEvent.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc03x001 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_LOAD = "load";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.multithrd.";
+ private final static String debuggerName = prefix + "tc03x001";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String exceptionName = debugeeName + "Exception";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static int eventCount = 0;
+
+ private EventRequestManager evm = null;
+ private ExceptionRequest exReq = null;
+ private volatile boolean exit = false;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+ tc03x001 thisTest = new tc03x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+ IOPipe pipe = debugee.createIOPipe();
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+ evm = debugee.getEventRequestManager();
+
+ ClassPrepareRequest crq = evm.createClassPrepareRequest();
+ crq.addClassFilter(exceptionName);
+ crq.enable();
+
+ // event handling thread
+ Thread eventHandler = new Thread() {
+ public void run() {
+ EventQueue eventQueue = debugee.VM().eventQueue();
+ EventSet eventSet = null;
+ while (!exit) {
+ try {
+ eventSet = eventQueue.remove(1000);
+ } catch (InterruptedException e) {
+ new Failure("Event handling thread interrupted:\n\t" + e);
+ }
+ if (eventSet == null) {
+ continue;
+ }
+ EventIterator eventIterator = eventSet.eventIterator();
+ while (eventIterator.hasNext()) {
+ Event event = eventIterator.nextEvent();
+
+ if (event instanceof ClassPrepareEvent) {
+ exReq = evm.createExceptionRequest(
+ ((ClassPrepareEvent )event).referenceType(),
+ true, false);
+ exReq.enable();
+ debugee.resume();
+
+ } else if (event instanceof ExceptionEvent) {
+ hitEvent((ExceptionEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } else {
+ throw new Failure("Unexpected event:\n\t" + event);
+ } // if
+ exit = exit || (eventCount >= tc03x001a.threadCount);
+ } // while
+ } // while
+ } // run()
+ }; // eventHadler
+
+ display("Starting handling event");
+ eventHandler.start();
+
+ debugee.resume();
+ debugee.receiveExpectedSignal(SGL_READY);
+
+ display("\nTEST BEGINS");
+ display("===========");
+ debugee.sendSignal(SGL_LOAD);
+
+ display("Waiting for all events received");
+ try {
+ eventHandler.join(waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("Main thread interrupted while waiting for eventHandler:\n\t"
+ + e);
+ } finally {
+ crq.disable();
+ exReq.disable();
+ exit = true;
+ if (eventHandler.isAlive()) {
+ display("Interrupting event handling thread");
+ eventHandler.interrupt();
+ }
+ }
+
+ if (eventCount < tc03x001a.threadCount) {
+ complain("expecting " + tc03x001a.threadCount
+ + " ExceptionEvents, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+ display("=============");
+ display("TEST FINISHES\n");
+ debugee.sendSignal(SGL_QUIT);
+ }
+
+ private void hitEvent(ExceptionEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ if (event.location().lineNumber() == tc03x001a.checkExBrkpLine) {
+ display("ExceptionEvent occurs on the expected line "
+ + event.location().lineNumber() + " in method "
+ + event.location().method().name());
+ } else {
+ complain("ExceptionEvent occurs stops on line " + event.location().lineNumber()
+ + " in method " + event.location().method().name()
+ + ", expected line number is "
+ + tc03x001a.checkExBrkpLine);
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("");
+
+ eventCount++;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001/TestDescription.java
new file mode 100644
index 00000000000..0b7eedb0560
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001/TestDescription.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/multithrd/tc03x001.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC3
+ * Description: Exception breakpoint
+ * Steps: 1.Set caught exception breakpoint on class
+ * javax.sound.midi.MidiUnavailableException
+ * 2.Debug Main
+ * X. Stops on line 42 in Main.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates ExceptionRequest.
+ * After ExceptionEvent arrived, debugger checks line number of one's
+ * location. It should be 74th line, that is throwing tc03x001aException.
+ * Every thread must generate ExceptionEvent.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ * Test fixed according to test bug:
+ * 4804095 TEST_BUG: potential race condition with loading classes in JDI tests
+ * - launching debuggee by prepareDebugee() replaced with bindToDebugee()
+ * to exclude first IOPipe communication
+ * - making ClassPrepareRequest moved to begin (right after debuggee started)
+ * - making ExceptionRequest moved to handling ClassPrepareEvent
+ * - handling events moved to a separate thread
+ * - removed extra IOPipe communication points to make algorithm more clear
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.multithrd.tc03x001
+ * nsk.jdi.BScenarios.multithrd.tc03x001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.multithrd.tc03x001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001a.java
new file mode 100644
index 00000000000..7fffcb24064
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001a.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc03x001a is deugee's part of the tc03x001.
+ */
+public class tc03x001a {
+
+ public final static int threadCount = 3;
+ static Log log;
+
+ public final static int checkExBrkpLine = 90;
+ Thready [] thrds = new Thready [threadCount];
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc03x001.SGL_READY);
+
+ tc03x001a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+
+ if (instr.equals(tc03x001.SGL_LOAD)) {
+ tc03x001aException.loadThis = true;
+ obj = new tc03x001a();
+ } else if (instr.equals(tc03x001.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ try {
+ for (int i = 0; i < obj.thrds.length; i++ ) {
+ obj.thrds[i].join();
+ }
+ } catch (InterruptedException e) {
+ }
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ tc03x001a() {
+ for (int i = 0; i < thrds.length; i++ ) {
+ thrds[i] = new Thready("Thread-" + (i+1));
+ thrds[i].start();
+ }
+ }
+
+ static class Thready extends Thread {
+ Thready(String name) {
+ super(name);
+ }
+
+ public void run() {
+ log.display(getName() + ":: throwing tc03x001aException");
+ try {
+ throw new tc03x001aException(); // checkExBrkpLine
+ } catch (tc03x001aException e) {
+ }
+ }
+ }
+}
+
+class tc03x001aException extends RuntimeException {
+
+ static boolean loadThis = false;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001.java
new file mode 100644
index 00000000000..c72ef73a416
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001.java
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC4
+ * Description: Exception breakpoint
+ * Steps: 1.Set method breakpoint on Main.foo()
+ * 2.Debug Main
+ * 3.Stops on line 27 in Main.java
+ *
+ * When the test is starting debugee, debugger creates MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks method name and if
+ * the one corresponds to specified name, it checks line number of the
+ * event location. It should be 64th line, that is method tc04x001a.foo.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc04x001 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_LOAD = "load";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.multithrd.";
+ private final static String debuggerName = prefix + "tc04x001";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String methodName = "foo";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static int brkpEventCount = 0;
+
+ private ClassType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc04x001 thisTest = new tc04x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.resume();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ MethodEntryRequest mthdReq = evm.createMethodEntryRequest();
+ display("MethodEntryRequest created, expecting events "
+ + "from method \"" + methodName + "\"");
+ display("---------------------------------------------"
+ + "-----------");
+ mthdReq.addClassFilter(debugeeName);
+ mthdReq.enable();
+
+ debugee.resume();
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+
+ if (event instanceof MethodEntryEvent) {
+ display(" event ===>>> " + " MethodEntryEvent arrived");
+ hitMethodBreakpoint((MethodEntryEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ exitStatus = Consts.TEST_FAILED;
+ }
+ if (brkpEventCount < tc04x001a.threadCount) {
+ complain("expecting " + tc04x001a.threadCount
+ + " MethodBreakpoint events, but "
+ + brkpEventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void hitMethodBreakpoint(MethodEntryEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ if (!event.method().name().equals(methodName)) {
+ display("the event skipped, method - " + event.method().name() + "\n");
+ return;
+ }
+
+ if (event.location().lineNumber() == tc04x001a.checkMethodBrkpLine) {
+ display("!!!MethodBreakpoint stops on the expected line "
+ + event.location().lineNumber() + " in method "
+ + "\"" + event.method().name() + "\"!!!");
+ } else {
+ complain("MethodBreakpoint stops on line " + event.location().lineNumber()
+ + " in method " + event.method().name()
+ + ", expected line number is "
+ + tc04x001a.checkMethodBrkpLine);
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("");
+
+ brkpEventCount++;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001/TestDescription.java
new file mode 100644
index 00000000000..e196970bf18
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001/TestDescription.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/multithrd/tc04x001.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC4
+ * Description: Exception breakpoint
+ * Steps: 1.Set method breakpoint on Main.foo()
+ * 2.Debug Main
+ * 3.Stops on line 27 in Main.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks method name and if
+ * the one corresponds to specified name, it checks line number of the
+ * event location. It should be 64th line, that is method tc04x001a.foo.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.multithrd.tc04x001
+ * nsk.jdi.BScenarios.multithrd.tc04x001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.multithrd.tc04x001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001a.java
new file mode 100644
index 00000000000..b7a68c487ee
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001a.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.multithrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc04x001a is deugee's part of the tc04x001.
+ */
+public class tc04x001a {
+
+ public final static int threadCount = 3;
+ static Log log;
+
+ public final static int checkMethodBrkpLine = 74;
+ Thready [] thrds = new Thready [threadCount];
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.out, argHandler);
+
+ tc04x001a obj = new tc04x001a();
+
+ for (int i = 0; i < obj.thrds.length; i++ ) {
+ try {
+ obj.thrds[i].join(argHandler.getWaitTime() * 60000);//obj.thrds[i].join();
+ if (!obj.thrds[i].isAlive()) {
+ log.display(obj.thrds[i].getName() + " finished");
+ } else {
+ log.display(obj.thrds[i].getName() + " not finished");
+ }
+ } catch (InterruptedException e) {
+ log.complain("DEBUGEE> " + obj.thrds[i].getName() + " didn't die.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ }
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ tc04x001a() {
+ for (int i = 0; i < thrds.length; i++ ) {
+ thrds[i] = new Thready("Thread-" + (i+1));
+ thrds[i].start();
+ }
+ }
+
+ public static void foo(String caller) {
+ log.display(caller + "::foo is called"); // checkMethodBrkpLine
+ }
+
+ public static void bar(String caller) {
+ log.display(caller + "::bar is called");
+ }
+
+ static class Thready extends Thread {
+ Thready(String name) {
+ super(name);
+ }
+
+ public void run() {
+ tc04x001a.foo(getName());
+ tc04x001a.bar(getName());
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x001.java
new file mode 100644
index 00000000000..337e3654c0f
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x001.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 1 - Breakpoints (single threads)
+ * Test case: TC1
+ * Description: Line breakpoint & step into
+ * Steps: 1.Set breakpoint on line 19
+ * 2.Debug Main
+ * X. Stops on line 19
+ * 3.Run | Step into three times
+ * X. Steps into Class1 constructor
+ *
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 48th line (method performTest).
+ * After the breakpoint is reached, debugger creates "step into" request
+ * and resumes debugee. StepRequest is created with specified
+ * addClassFilter. For the third StepEvent debugger
+ * checks line number of one's location. It should be 56th line.
+ *
+ * In case, when line number of event is wrong, test fails.
+ */
+
+public class tc01x001 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.singlethrd.";
+ private final static String debuggerName = prefix + "tc01x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private final static int expectedStepEventCount = 3;
+ private static int stepEventCount = 0;
+
+ private ClassType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc01x001 thisTest = new tc01x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.resume();
+ debugee.quit();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ debugeeClass = (ClassType)debugee.classByName(debugeeName);
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ display("Tested class\t:" + debugeeClass.name());
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ StepRequest step = null;
+
+ debugee.setBreakpoint(debugeeClass,
+ tc01x001a.brkpMethodName,
+ tc01x001a.brkpLineNumber);
+ debugee.resume();
+ debugee.sendSignal(SGL_PERFORM);
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display(" event ===>>> " + event);
+
+ if (event instanceof BreakpointEvent) {
+ display(" event ===>>> " + event);
+ hitBreakpoint((BreakpointEvent )event);
+ step = evm.createStepRequest(((BreakpointEvent )event).thread(),
+ StepRequest.STEP_LINE,
+ StepRequest.STEP_INTO);
+ step.addClassFilter(prefix + "*");
+ step.enable();
+ debugee.resume();
+
+ } else if (event instanceof StepEvent) {
+ display(" event ===>>> " + event);
+ hitStepInto((StepEvent )event);
+ if (stepEventCount >= expectedStepEventCount) {
+ evm.deleteEventRequest(step);
+ }
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ exit = exit || (stepEventCount == expectedStepEventCount);
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (stepEventCount < expectedStepEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedStepEventCount
+ + " step events, but "
+ + stepEventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void hitBreakpoint(BreakpointEvent event) {
+ display("BreakpointEvent arrived. Location - "
+ + event.location().lineNumber() + " line");
+ display("");
+ }
+
+ private void hitStepInto(StepEvent event) {
+ stepEventCount++;
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ if (stepEventCount == expectedStepEventCount) {
+ if (event.location().lineNumber() != tc01x001a.checkLastLine) {
+ complain("StepEvent steps to line " + event.location().lineNumber()
+ + ", expected line number is "
+ + tc01x001a.checkLastLine);
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("StepEvent steps to the expected line "
+ + event.location().lineNumber());
+ }
+ }
+ display("");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x001/TestDescription.java
new file mode 100644
index 00000000000..57d1b678427
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x001/TestDescription.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/singlethrd/tc01x001.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 1 - Breakpoints (single threads)
+ * Test case: TC1
+ * Description: Line breakpoint & step into
+ * Steps: 1.Set breakpoint on line 19
+ * 2.Debug Main
+ * X. Stops on line 19
+ * 3.Run | Step into three times
+ * X. Steps into Class1 constructor
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 48th line (method "performTest").
+ * After the breakpoint is reached, debugger creates "step into" request
+ * and resumes debugee. StepRequest is created with specified addClassFilter.
+ * For the third StepEvent debugger checks line number of one's location.
+ * It should be 56th line.
+ * In case, when line number of event is wrong, test fails.
+ * COMMENTS:
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.singlethrd.tc01x001
+ * nsk.jdi.BScenarios.singlethrd.tc01x001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.singlethrd.tc01x001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x001a.java
new file mode 100644
index 00000000000..79932cc1d46
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x001a.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc01x001a is deugee's part of the tc01x001.
+ */
+public class tc01x001a {
+
+ public final static String brkpMethodName = "performTest";
+ public final static int brkpLineNumber = 69;
+
+ public final static int checkLastLine = 76;
+ static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc01x001.SGL_READY);
+
+ tc01x001a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ if (instr.equals(tc01x001.SGL_PERFORM)) {
+ performTest();
+ } else if (instr.equals(tc01x001.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void performTest() {
+ log.display("performTest::line 0");
+ log.display("performTest::breakpoint line"); // brkpLineNumber
+ log.display("performTest::creating tc01x001aClass1 object");
+ new tc01x001aClass1();
+ }
+}
+
+class tc01x001aClass1 {
+ tc01x001aClass1() { // checkLastLine
+ tc01x001a.log.display("tc01x001aClass1::constructor is called");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x002.java
new file mode 100644
index 00000000000..b5ac0a1590c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x002.java
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 1 - Breakpoints (single threads)
+ * Test case: TC1
+ * Description: Line breakpoint & step into
+ * Steps: 1.Set breakpoint on line 19
+ * 2.Debug Main
+ * X. Stops on line 19
+ * 3.Run | Step into three times
+ * X. Steps into Class1 constructor
+ *
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 49th line (method performTest).
+ * After the breakpoint is reached, debugger creates "step into" request
+ * and resumes debugee. StepRequest is created with specified
+ * addClassExclusionFilter. For the third StepEvent
+ * debugger checks line number of one's location. It should be 56th line.
+ *
+ * In case, when line number of event is wrong, test fails.
+ */
+
+public class tc01x002 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.singlethrd.";
+ private final static String debuggerName = prefix + "tc01x002";
+ private final static String debugeeName = debuggerName + "a";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private final static int expectedStepEventCount = 3;
+ private static int stepEventCount = 0;
+
+ private ClassType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc01x002 thisTest = new tc01x002();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.resume();
+ debugee.quit();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ debugeeClass = (ClassType)debugee.classByName(debugeeName);
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ display("Tested class\t:" + debugeeClass.name());
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ StepRequest step = null;
+
+ debugee.setBreakpoint(debugeeClass,
+ tc01x002a.brkpMethodName,
+ tc01x002a.brkpLineNumber);
+ debugee.resume();
+ debugee.sendSignal(SGL_PERFORM);
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display(" event ===>>> " + event);
+
+ if (event instanceof BreakpointEvent) {
+ display(" event ===>>> " + event);
+ hitBreakpoint((BreakpointEvent )event);
+ step = evm.createStepRequest(((BreakpointEvent )event).thread(),
+ StepRequest.STEP_LINE,
+ StepRequest.STEP_INTO);
+ step.addClassExclusionFilter("nsk.share.*");
+ step.addClassExclusionFilter("java.*");
+ step.addClassExclusionFilter("sun.*");
+ step.addClassExclusionFilter("oracle.*");
+ step.addClassExclusionFilter("jdk.jfr.*");
+ step.addClassExclusionFilter("com.oracle.*");
+ step.addClassExclusionFilter("jdk.internal.*");
+ step.enable();
+ debugee.resume();
+
+ } else if (event instanceof StepEvent) {
+ display(" event ===>>> " + event);
+ hitStepInto((StepEvent )event);
+ if (stepEventCount >= expectedStepEventCount) {
+ evm.deleteEventRequest(step);
+ }
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ exit = exit || (stepEventCount == expectedStepEventCount);
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (stepEventCount < expectedStepEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedStepEventCount
+ + " step events, but "
+ + stepEventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void hitBreakpoint(BreakpointEvent event) {
+ display("BreakpointEvent arrived. Location - "
+ + event.location().lineNumber() + " line");
+ display("");
+ }
+
+ private void hitStepInto(StepEvent event) {
+ stepEventCount++;
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ if (stepEventCount == expectedStepEventCount) {
+ if (event.location().lineNumber() != tc01x002a.checkLastLine) {
+ complain("StepEvent steps to line " + event.location().lineNumber()
+ + ", expected line number is "
+ + tc01x002a.checkLastLine);
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("StepEvent steps to the expected line "
+ + event.location().lineNumber());
+ }
+ }
+ display("");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x002/TestDescription.java
new file mode 100644
index 00000000000..830fa9006db
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x002/TestDescription.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/singlethrd/tc01x002.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 1 - Breakpoints (single threads)
+ * Test case: TC1
+ * Description: Line breakpoint & step into
+ * Steps: 1.Set breakpoint on line 19
+ * 2.Debug Main
+ * X. Stops on line 19
+ * 3.Run | Step into three times
+ * X. Steps into Class1 constructor
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 49th line (method "performTest").
+ * After the breakpoint is reached, debugger creates "step into" request
+ * and resumes debugee. StepRequest is created with specified
+ * addClassExclusionFilter. For the third StepEvent debugger checks line
+ * number of one's location. It should be 56th line.
+ * In case, when line number of event is wrong, test fails.
+ * COMMENTS:
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.singlethrd.tc01x002
+ * nsk.jdi.BScenarios.singlethrd.tc01x002a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.singlethrd.tc01x002
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x002a.java
new file mode 100644
index 00000000000..6fb97d2d52d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc01x002a.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc01x002a is deugee's part of the tc01x002.
+ */
+public class tc01x002a {
+
+ public final static String brkpMethodName = "performTest";
+ public final static int brkpLineNumber = 69;
+
+ public final static int checkLastLine = 76;
+ static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc01x002.SGL_READY);
+
+ tc01x002a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ if (instr.equals(tc01x002.SGL_PERFORM)) {
+ performTest();
+ } else if (instr.equals(tc01x002.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void performTest() {
+ log.display("performTest::line 0");
+ log.display("performTest::breakpoint line"); // brkpLineNumber
+ log.display("performTest::creating tc01x002aClass1 object");
+ new tc01x002aClass1();
+ }
+}
+
+class tc01x002aClass1 {
+ tc01x002aClass1() { // checkLastLine
+ tc01x002a.log.display("tc01x002aClass1::constructor is called");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc02x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc02x001.java
new file mode 100644
index 00000000000..80e3b1df992
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc02x001.java
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 1 - Breakpoints (single threads)
+ * Test case: TC2
+ * Description: Line breakpoint & step over
+ * Steps: 1.Set breakpoint on line 19
+ * 2.Debug Main
+ * X. Stops on line 19
+ * 3.Run | Step over three times
+ * X. Stops on line 22 in Main.java
+ *
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 49th line (method "performTest").
+ * After the breakpoint is reached, debugger creates "step over" request
+ * and resumes debugee. For the third StepEvent debugger checks line
+ * number of one's location. It should be 52th line.
+ *
+ * In case, when line number of event is wrong, test fails.
+ */
+
+public class tc02x001 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.singlethrd.";
+ private final static String debuggerName = prefix + "tc02x001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private final static int expectedStepEventCount = 3;
+ private static int stepEventCount = 0;
+
+ private ClassType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc02x001 thisTest = new tc02x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.resume();
+ debugee.quit();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ debugeeClass = (ClassType)debugee.classByName(debugeeName);
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ display("Tested class\t:" + debugeeClass.name());
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ StepRequest step = null;
+
+ debugee.setBreakpoint(debugeeClass,
+ tc02x001a.brkpMethodName,
+ tc02x001a.brkpLineNumber);
+ debugee.resume();
+ debugee.sendSignal(SGL_PERFORM);
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display(" event ===>>> " + event);
+
+ if (event instanceof BreakpointEvent) {
+ display(" event ===>>> " + event);
+ hitBreakpoint((BreakpointEvent )event);
+ step = evm.createStepRequest(((BreakpointEvent )event).thread(),
+ StepRequest.STEP_LINE,
+ StepRequest.STEP_OVER);
+ step.enable();
+ debugee.resume();
+
+ } else if (event instanceof StepEvent) {
+ display(" event ===>>> " + event);
+ hitStepOver((StepEvent )event);
+ if (stepEventCount >= expectedStepEventCount) {
+ evm.deleteEventRequest(step);
+ }
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ exit = exit || (stepEventCount == expectedStepEventCount);
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (stepEventCount < expectedStepEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedStepEventCount
+ + " step events, but "
+ + stepEventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void hitBreakpoint(BreakpointEvent event) {
+ display("BreakpointEvent arrived. Location - "
+ + event.location().lineNumber() + " line");
+ display("");
+ }
+
+ private void hitStepOver(StepEvent event) {
+ stepEventCount++;
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ if (stepEventCount == expectedStepEventCount) {
+ if (event.location().lineNumber() != tc02x001a.checkLastLine) {
+ complain("StepEvent steps to line " + event.location().lineNumber()
+ + ", expected line number is "
+ + tc02x001a.checkLastLine);
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("StepEvent steps to the expected line "
+ + event.location().lineNumber());
+ }
+ }
+ display("");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc02x001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc02x001/TestDescription.java
new file mode 100644
index 00000000000..f791e5192e7
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc02x001/TestDescription.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/singlethrd/tc02x001.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 1 - Breakpoints (single threads)
+ * Test case: TC2
+ * Description: Line breakpoint & step over
+ * Steps: 1.Set breakpoint on line 19
+ * 2.Debug Main
+ * X. Stops on line 19
+ * 3.Run | Step over three times
+ * X. Stops on line 22 in Main.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger sets breakpoint at
+ * the 49th line (method "performTest").
+ * After the breakpoint is reached, debugger creates "step over" request
+ * and resumes debugee. For the third StepEvent debugger checks line
+ * number of one's location. It should be 52th line.
+ * In case, when line number of event is wrong, test fails.
+ * COMMENTS:
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.singlethrd.tc02x001
+ * nsk.jdi.BScenarios.singlethrd.tc02x001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.singlethrd.tc02x001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc02x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc02x001a.java
new file mode 100644
index 00000000000..6b95d216fd6
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc02x001a.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc02x001a is deugee's part of the tc02x001.
+ */
+public class tc02x001a {
+
+ public final static String brkpMethodName = "performTest";
+ public final static int brkpLineNumber = 68;
+
+ public final static int checkLastLine = 71;
+ static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc02x001.SGL_READY);
+
+ tc02x001a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ if (instr.equals(tc02x001.SGL_PERFORM)) {
+ performTest();
+ } else if (instr.equals(tc02x001.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void performTest() {
+ log.display("performTest::line 0"); // brkpLineNumber
+ log.display("performTest::breakpoint line");
+ log.display("performTest::creating tc02x001aClass1 object");
+ new tc02x001aClass1(); // checkLastLine
+ log.display("performTest::tc02x001aClass1 object is created");
+ }
+}
+
+class tc02x001aClass1 {
+ tc02x001aClass1() {
+ tc02x001a.log.display("tc02x001aClass1::constructor is called");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x001.java
new file mode 100644
index 00000000000..fe2fec7036c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x001.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc03x001aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc03x001 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.singlethrd.";
+ private final static String debuggerName = prefix + "tc03x001";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String testedClassName = debugeeName + "Class1";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private final static int expectedEventCount = 1;
+ private static int eventCount = 0;
+
+ private ClassType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc03x001 thisTest = new tc03x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.resume();
+ debugee.quit();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ debugeeClass = (ClassType)debugee.classByName(debugeeName);
+ display("Tested class\t:" + debugeeClass.name());
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+
+ EventRequestManager evm = debugee.getEventRequestManager();
+ MethodEntryRequest mthdReq = evm.createMethodEntryRequest();
+ mthdReq.addClassFilter(testedClassName);
+ mthdReq.enable();
+
+ debugee.resume();
+ debugee.sendSignal(SGL_PERFORM);
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display(" event ===>>> " + event);
+
+ if (event instanceof MethodEntryEvent) {
+ display(" event ===>>> " + event);
+ hitClassBreakpoint((MethodEntryEvent )event);
+ debugee.resume();
+ exit = true;
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (eventCount < expectedEventCount) {
+ if (totalTime <= 0) {
+ complain("out of wait time...");
+ }
+ complain("expecting " + expectedEventCount
+ + " breakpoint events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void hitClassBreakpoint(MethodEntryEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ if (event.location().lineNumber() == tc03x001a.checkLastLine) {
+ display("ClassBreakpoint stops on the expected line "
+ + event.location().lineNumber() + " in method "
+ + event.method().name());
+ } else {
+ complain("ClassBreakpoint stops on line " + event.location().lineNumber()
+ + " in method " + event.method().name()
+ + ", expected line number is "
+ + tc03x001a.checkLastLine);
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ eventCount++;
+
+ display("");
+
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x001/TestDescription.java
new file mode 100644
index 00000000000..1d7ea063201
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x001/TestDescription.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/singlethrd/tc03x001.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC2
+ * Description: Class breakpoint
+ * Steps: 1.Add class breakpoint: singlethread.Class1
+ * 2.Debug Main
+ * X. Stops on line 13 in Class1.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc02x001aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * There are a doublness of the "class breakpoint" understanding.
+ * Here is that JBuilder help says:
+ * 1. "A class breakpoint causes the debugger to stop when any method
+ * from the specified class is called or when the specified class
+ * is instantiated."
+ * So, a class breakpoint is MethodEntryRequest with filtering
+ * the specified class.
+ * 2. "A class breakpoint causes the debugger to stop at the location
+ * when the specified class is loaded or when any method from the
+ * specified class is called."
+ * In this case, a class breakpoint is MethodEntryRequest and
+ * ClassPrepareRequest with filtering the specified class.
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.singlethrd.tc03x001
+ * nsk.jdi.BScenarios.singlethrd.tc03x001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.singlethrd.tc03x001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x001a.java
new file mode 100644
index 00000000000..1469638c84d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x001a.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc03x001a is deugee's part of the tc02x001.
+ */
+public class tc03x001a {
+
+ public final static String brkpMethodName = "performTest";
+ public final static int brkpLineNumber = 1;
+
+ public final static int checkLastLine = 77;
+ static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc03x001.SGL_READY);
+
+ tc03x001a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ if (instr.equals(tc03x001.SGL_PERFORM)) {
+ performTest();
+ } else if (instr.equals(tc03x001.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void performTest() {
+ log.display("performTest::line 0");
+ log.display("performTest::breakpoint line");
+ log.display("performTest::creating tc03x001aClass1 object");
+ new tc03x001aClass1();
+ log.display("performTest::tc03x001aClass1 object is created");
+ }
+}
+
+class tc03x001aClass1 {
+ tc03x001aClass1() { // checkLastLine
+ tc03x001a.log.display("tc03x001aClass1::constructor is called");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x002.java
new file mode 100644
index 00000000000..245d923a4ac
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x002.java
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc03x002aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc03x002 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_LOAD = "load";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.singlethrd.";
+ private final static String debuggerName = prefix + "tc03x002";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String testedClassName = debugeeName + "Class1";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static int eventCount = 0;
+ private final static int expectedEventCount = 2;
+
+ private EventRequestManager evm = null;
+ private MethodEntryRequest mthdReq = null;
+ private volatile boolean exit = false;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+ tc03x002 thisTest = new tc03x002();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+ IOPipe pipe = debugee.createIOPipe();
+
+ try {
+ thisTest.execTest();
+ } catch (Exception e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+ evm = debugee.getEventRequestManager();
+
+ ClassPrepareRequest crq = evm.createClassPrepareRequest();
+ crq.addClassFilter(testedClassName);
+ crq.enable();
+
+ // event handling thread
+ Thread eventHandler = new Thread() {
+ public void run() {
+ EventQueue eventQueue = debugee.VM().eventQueue();
+ EventSet eventSet = null;
+ while (!exit) {
+ try {
+ eventSet = eventQueue.remove(1000);
+ } catch (InterruptedException e) {
+ new Failure("Event handling thread interrupted:\n\t" + e);
+ }
+ if (eventSet == null) {
+ continue;
+ }
+ EventIterator eventIterator = eventSet.eventIterator();
+ while (eventIterator.hasNext()) {
+ Event event = eventIterator.nextEvent();
+
+ if (event instanceof ClassPrepareEvent) {
+ display(" event ===>>> " + event);
+ mthdReq = evm.createMethodEntryRequest();
+ mthdReq.addClassFilter(testedClassName);
+ mthdReq.enable();
+ debugee.resume();
+
+ } else if (event instanceof MethodEntryEvent) {
+ display(" event ===>>> " + event);
+ hitEvent((MethodEntryEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } else {
+ throw new Failure("Unexpected event:\n\t" + event);
+ } // if
+ exit = exit || (eventCount >= expectedEventCount);
+ } // while
+ } // while
+ } // run()
+ }; // eventHadler
+
+ display("Starting handling event");
+ eventHandler.start();
+
+ debugee.resume();
+ debugee.receiveExpectedSignal(SGL_READY);
+
+ display("\nTEST BEGINS");
+ display("===========");
+ debugee.sendSignal(SGL_LOAD);
+
+ display("Waiting for all events received");
+ try {
+ eventHandler.join(waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("Main thread interrupted while waiting for eventHandler:\n\t"
+ + e);
+ } finally {
+ crq.disable();
+ mthdReq.disable();
+ exit = true;
+ if (eventHandler.isAlive()) {
+ display("Interrupting event handling thread");
+ eventHandler.interrupt();
+ }
+ }
+
+ if (eventCount < expectedEventCount) {
+ complain("Expecting " + expectedEventCount
+ + " MethodEntryEvents, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ debugee.sendSignal(SGL_QUIT);
+ }
+
+ private void hitEvent(MethodEntryEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ eventCount++;
+ if (event.location().lineNumber() == tc03x002a.checkLastLine1 ||
+ event.location().lineNumber() == tc03x002a.checkLastLine2) {
+ display("MethodEntryEvent occurs on the expected line "
+ + event.location().lineNumber() + " in method "
+ + event.method().name());
+ } else {
+ complain("MethodEntryEvent occurs on line " + event.location().lineNumber()
+ + " in method " + event.method().name()
+ + ", expected line numbers are "
+ + tc03x002a.checkLastLine1 + " or "
+ + tc03x002a.checkLastLine2);
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x002/TestDescription.java
new file mode 100644
index 00000000000..6cfc53b6c17
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x002/TestDescription.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/singlethrd/tc03x002.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC2
+ * Description: Class breakpoint
+ * Steps: 1.Add class breakpoint: singlethread.Class1
+ * 2.Debug Main
+ * X. Stops on line 13 in Class1.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc02x001aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * There are a doublness of the "class breakpoint" understanding.
+ * Here is that JBuilder help says:
+ * 1. "A class breakpoint causes the debugger to stop when any method
+ * from the specified class is called or when the specified class
+ * is instantiated."
+ * So, a class breakpoint is MethodEntryRequest with filtering
+ * the specified class.
+ * 2. "A class breakpoint causes the debugger to stop at the location
+ * when the specified class is loaded or when any method from the
+ * specified class is called."
+ * In this case, a class breakpoint is MethodEntryRequest and
+ * ClassPrepareRequest with filtering the specified class.
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ * Test fixed according to test bug:
+ * 4804095 TEST_BUG: potential race condition with loading classes in JDI tests
+ * - launching debuggee by prepareDebugee() replaced with bindToDebugee()
+ * to exclude first IOPipe communication
+ * - making ClassPrepareRequest moved to begin (right after debuggee started)
+ * - making MethodEntryRequest moved to handling ClassPrepareEvent
+ * - handling events moved to a separate thread
+ * - removed extra IOPipe communication points to make algorithm more clear
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.singlethrd.tc03x002
+ * nsk.jdi.BScenarios.singlethrd.tc03x002a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.singlethrd.tc03x002
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x002a.java
new file mode 100644
index 00000000000..c66b256bd5e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x002a.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc03x002a is deugee's part of the tc02x001.
+ */
+public class tc03x002a {
+
+ public final static int checkLastLine1 = 76;
+ public final static int checkLastLine2 = 78;
+ static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc03x002.SGL_READY);
+
+ tc03x002a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ log.display("instruction \"" + instr +"\"");
+ if (instr.equals(tc03x002.SGL_LOAD)) {
+ tc03x002aClass1.loadThis = true;
+ performTest();
+ } else if (instr.equals(tc03x002.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void performTest() {
+ log.display("performTest::creating tc03x002aClass1 object");
+ new tc03x002aClass1();
+ log.display("performTest::tc03x002aClass1 object is created");
+ }
+}
+
+class tc03x002aClass1 {
+
+ static boolean loadThis = false; // checkLastLine1
+
+ tc03x002aClass1() { // checkLastLine2
+ tc03x002a.log.display("tc03x002aClass1::constructor is called");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x003.java
new file mode 100644
index 00000000000..7687f8fdd36
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x003.java
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc03x003aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc03x003 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_LOAD = "load";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.singlethrd.";
+ private final static String debuggerName = prefix + "tc03x003";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String testedClassName = debugeeName + "Class1";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private static int eventCount = 0;
+ private final static int expectedEventCount = 3;
+
+ private EventRequestManager evm = null;
+ private MethodEntryRequest mthdReq = null;
+ private volatile boolean exit = false;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+ tc03x003 thisTest = new tc03x003();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+ IOPipe pipe = debugee.createIOPipe();
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+ evm = debugee.getEventRequestManager();
+
+ ClassPrepareRequest crq = evm.createClassPrepareRequest();
+ crq.addClassFilter(testedClassName);
+ crq.enable();
+
+ // separate thread to handle event
+ Thread eventHandler = new Thread() {
+ public void run() {
+ EventQueue eventQueue = debugee.VM().eventQueue();
+ while (!exit) {
+ EventSet eventSet = null;
+ try {
+ eventSet = eventQueue.remove(1000);
+ } catch (InterruptedException e) {
+ new Failure("Event handling thread interrupted:\n\t" + e);
+ }
+ if (eventSet == null) {
+ continue;
+ }
+ EventIterator eventIterator = eventSet.eventIterator();
+ while (eventIterator.hasNext()) {
+ Event event = eventIterator.nextEvent();
+
+ if (event instanceof ClassPrepareEvent) {
+ display(" event ===>>> " + event);
+ ClassPrepareEvent clsEvent = (ClassPrepareEvent)event;
+ hitEvent(clsEvent);
+
+ mthdReq = evm.createMethodEntryRequest();
+ ReferenceType testedClass = clsEvent.referenceType();
+ mthdReq.addClassFilter(testedClass);
+ mthdReq.enable();
+
+ debugee.resume();
+
+ } else if (event instanceof MethodEntryEvent) {
+ display(" event ===>>> " + event);
+ hitEvent((MethodEntryEvent )event);
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } else {
+ throw new Failure("Unexpected event received:\n\t" + event);
+ } // if
+ exit = exit || (eventCount >= expectedEventCount);
+ } // while
+ } // while
+ } // run()
+ }; // eventHandler
+
+ display("Starting handling event");
+ eventHandler.start();
+
+ debugee.resume();
+ debugee.receiveExpectedSignal(SGL_READY);
+
+ display("\nTEST BEGINS");
+ display("===========");
+ debugee.sendSignal(SGL_LOAD);
+
+ display("Waiting for all events received");
+ try {
+ eventHandler.join(waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("Main thread interrupted while waiting for eventHandler:\n\t"
+ + e);
+ } finally {
+ crq.disable();
+ mthdReq.disable();
+ exit = true;
+ if (eventHandler.isAlive()) {
+ display("Interrupting event handling thread");
+ eventHandler.interrupt();
+ }
+ }
+
+ if (eventCount < expectedEventCount) {
+ complain("Expecting " + expectedEventCount
+ + " BreakpointEvents, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ debugee.sendSignal(SGL_QUIT);
+ }
+
+ private void hitEvent(MethodEntryEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ eventCount++;
+ if (event.location().lineNumber() == tc03x003a.checkLastLine1 ||
+ event.location().lineNumber() == tc03x003a.checkLastLine2) {
+ display("MethodEntryEvent occurs stops on the expected line "
+ + event.location().lineNumber() + " in method "
+ + event.method().name());
+ } else {
+ complain("MewthodEntryEvent occurs on line " + event.location().lineNumber()
+ + " in method " + event.method().name()
+ + ", expected line numbers are "
+ + tc03x003a.checkLastLine1 + " or "
+ + tc03x003a.checkLastLine2);
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("");
+
+ }
+
+ private void hitEvent(ClassPrepareEvent event) {
+ display("ClassPrepareEvent occurs\n");
+ eventCount++;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x003/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x003/TestDescription.java
new file mode 100644
index 00000000000..7a9f9b16736
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x003/TestDescription.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/singlethrd/tc03x003.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC2
+ * Description: Class breakpoint
+ * Steps: 1.Add class breakpoint: singlethread.Class1
+ * 2.Debug Main
+ * X. Stops on line 13 in Class1.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc02x001aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * There are a doublness of the "class breakpoint" understanding.
+ * Here is that JBuilder help says:
+ * 1. "A class breakpoint causes the debugger to stop when any method
+ * from the specified class is called or when the specified class
+ * is instantiated."
+ * So, a class breakpoint is MethodEntryRequest with filtering
+ * the specified class.
+ * 2. "A class breakpoint causes the debugger to stop at the location
+ * when the specified class is loaded or when any method from the
+ * specified class is called."
+ * In this case, a class breakpoint is MethodEntryRequest and
+ * ClassPrepareRequest with filtering the specified class.
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ * Test fixed according to test bug:
+ * 4804095 TEST_BUG: potential race condition with loading classes in JDI tests
+ * - launching debuggee by prepareDebugee() replaced with bindToDebugee()
+ * to exclude first IOPipe communication
+ * - making ClassPrepareRequest moved to begin (right after debuggee started)
+ * - making MethodEntryRequest moved to handling ClassPrepareEvent
+ * - handling events moved to a separate thread
+ * - removed extra IOPipe communication points to make algorithm more clear
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.singlethrd.tc03x003
+ * nsk.jdi.BScenarios.singlethrd.tc03x003a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.singlethrd.tc03x003
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x003a.java
new file mode 100644
index 00000000000..acc5a484c17
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc03x003a.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc03x003a is deugee's part of the tc02x001.
+ */
+public class tc03x003a {
+
+ public final static int checkLastLine1 = 76;
+ public final static int checkLastLine2 = 78;
+ static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc03x003.SGL_READY);
+
+ tc03x003a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ log.display("instruction \"" + instr +"\"");
+ if (instr.equals(tc03x003.SGL_LOAD)) {
+ tc03x003aClass1.loadThis = true;
+ performTest();
+ } else if (instr.equals(tc03x003.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void performTest() {
+ log.display("performTest::creating tc03x003aClass1 object");
+ new tc03x003aClass1();
+ log.display("performTest::tc03x003aClass1 object is created");
+ }
+}
+
+class tc03x003aClass1 {
+
+ static boolean loadThis = false; // checkLastLine1
+
+ tc03x003aClass1() { // checkLastLine2
+ tc03x003a.log.display("tc03x003aClass1::constructor is called");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc04x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc04x001.java
new file mode 100644
index 00000000000..4297b956a52
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc04x001.java
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc04x001aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc04x001 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_LOAD = "load";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.singlethrd.";
+ private final static String debuggerName = prefix + "tc04x001";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String exceptionName = debugeeName + "Exception";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private final static int expectedEventCount = 1;
+ private static int eventCount = 0;
+
+ private EventRequestManager evm = null;
+ private ExceptionRequest exReq = null;
+ private volatile boolean exit = false;
+
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+ tc04x001 thisTest = new tc04x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ Binder binder = new Binder(argHandler, log);
+ debugee = binder.bindToDebugee(debugeeName);
+ IOPipe pipe = debugee.createIOPipe();
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.endDebugee();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+ evm = debugee.getEventRequestManager();
+
+ ClassPrepareRequest crq = evm.createClassPrepareRequest();
+ crq.addClassFilter(exceptionName);
+ crq.enable();
+
+ // separate thread to handle event
+ Thread eventHandler = new Thread() {
+ public void run() {
+ EventQueue eventQueue = debugee.VM().eventQueue();
+ while (!exit) {
+ EventSet eventSet = null;
+ try {
+ eventSet = eventQueue.remove(1000);
+ } catch (InterruptedException e) {
+ new Failure("Event handling thread interrupted:\n\t" + e);
+ }
+ if (eventSet == null) {
+ continue;
+ }
+ EventIterator eventIterator = eventSet.eventIterator();
+ while (eventIterator.hasNext()) {
+ Event event = eventIterator.nextEvent();
+
+ if (event instanceof ClassPrepareEvent) {
+ display(" event ===>>> " + event);
+ exReq = evm.createExceptionRequest(
+ ((ClassPrepareEvent )event).referenceType(),
+ true, false);
+ exReq.enable();
+ debugee.resume();
+
+ } else if (event instanceof ExceptionEvent) {
+ display(" event ===>>> " + event);
+ hitEvent((ExceptionEvent )event);
+ exReq.disable();
+ debugee.resume();
+ exit = true;
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } else {
+ throw new Failure("Unexpected event received:\n\t" + event);
+ } // if
+ } // while
+ } // while
+ } // run()
+ }; // eventHandler
+
+ display("Starting handling event");
+ eventHandler.start();
+
+ debugee.resume();
+ debugee.receiveExpectedSignal(SGL_READY);
+
+ display("\nTEST BEGINS");
+ display("===========");
+ debugee.sendSignal(SGL_LOAD);
+
+ display("Waiting for all events received");
+ try {
+ eventHandler.join(waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("Main thread interrupted while waiting for eventHandler:\n\t"
+ + e);
+ } finally {
+ crq.disable();
+ exReq.disable();
+ exit = true;
+ if (eventHandler.isAlive()) {
+ display("Interrupting event handling thread");
+ eventHandler.interrupt();
+ }
+ }
+
+ if (eventCount < expectedEventCount) {
+ complain("expecting " + expectedEventCount
+ + " breakpoint events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ debugee.sendSignal(SGL_QUIT);
+ }
+
+ private void hitEvent(ExceptionEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ if (event.location().lineNumber() == tc04x001a.checkExBrkpLine) {
+ display("ExceptionEvent occurs on the expected line "
+ + event.location().lineNumber() + " in method "
+ + event.location().method().name());
+ } else {
+ complain("ExceptionEvent occurs on line " + event.location().lineNumber()
+ + " in method " + event.location().method().name()
+ + ", expected line number is "
+ + tc04x001a.checkExBrkpLine);
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ eventCount++;
+ display("");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc04x001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc04x001/TestDescription.java
new file mode 100644
index 00000000000..7aafe7a7560
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc04x001/TestDescription.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/singlethrd/tc04x001.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC3
+ * Description: Exception breakpoint
+ * Steps: 1.Set caught exception breakpoint on class
+ * javax.sound.midi.MidiUnavailableException
+ * 2.Debug Main
+ * X. Stops on line 42 in Main.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates ExceptionRequest.
+ * After ExceptionEvent arrived, debugger checks line number of one's
+ * location. It should be 74th line, that is throwing tc03x001aException.
+ * Every thread must generate ExceptionEvent.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ * Test fixed according to test bug:
+ * 4804095 TEST_BUG: potential race condition with loading classes in JDI tests
+ * - launching debuggee by prepareDebugee() replaced with bindToDebugee()
+ * to exclude first IOPipe communication
+ * - making ClassPrepareRequest moved to begin (right after debuggee started)
+ * - making ExceptionRequest moved to handling ClassPrepareEvent
+ * - handling events moved to a separate thread
+ * - removed extra IOPipe communication points to make algorithm more clear
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.singlethrd.tc04x001
+ * nsk.jdi.BScenarios.singlethrd.tc04x001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.singlethrd.tc04x001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc04x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc04x001a.java
new file mode 100644
index 00000000000..5f0ba801666
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc04x001a.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc04x001a is deugee's part of the tc02x001.
+ */
+public class tc04x001a {
+
+ public final static int checkExBrkpLine = 69;
+ static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc04x001.SGL_READY);
+
+ tc04x001a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ log.display("instruction \"" + instr +"\"");
+ if (instr.equals(tc04x001.SGL_LOAD)) {
+ tc04x001aException.loadThis = true;
+ performTest();
+ } else if (instr.equals(tc04x001.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void performTest() {
+ log.display("performTest:: throwing tc04x001aException");
+ try {
+ throw new tc04x001aException(); // checkExBrkpLine
+ } catch (tc04x001aException e) {
+ }
+ }
+}
+
+class tc04x001aException extends RuntimeException {
+ static boolean loadThis = false;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc05x001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc05x001.java
new file mode 100644
index 00000000000..8a71e950723
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc05x001.java
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case: MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc05x001aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ *
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ */
+
+public class tc05x001 {
+
+ public final static String SGL_READY = "ready";
+ public final static String SGL_PERFORM = "perform";
+ public final static String SGL_QUIT = "quit";
+
+ private final static String prefix = "nsk.jdi.BScenarios.singlethrd.";
+ private final static String debuggerName = prefix + "tc05x001";
+ private final static String debugeeName = debuggerName + "a";
+ private final static String testedClassName = debugeeName + "Class1";
+ private final static String methodName = "bar";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+ private final static int expectedEventCount = 1;
+ private static int eventCount = 0;
+
+ private ClassType debugeeClass;
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ tc05x001 thisTest = new tc05x001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Throwable e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ debugee.resume();
+ debugee.quit();
+ }
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure {
+
+ debugeeClass = (ClassType)debugee.classByName(debugeeName);
+ display("Tested class\t:" + debugeeClass.name());
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ EventSet eventSet = null;
+ EventIterator eventIterator = null;
+ Event event;
+ long totalTime = waitTime;
+ long tmp, begin = System.currentTimeMillis(),
+ delta = 0;
+ boolean exit = false;
+ EventRequestManager evm = debugee.getEventRequestManager();
+ MethodEntryRequest mthdReq = null;
+
+ mthdReq = evm.createMethodEntryRequest();
+ mthdReq.addClassFilter(testedClassName);
+ mthdReq.enable();
+
+ debugee.resume();
+ debugee.sendSignal(SGL_PERFORM);
+
+ while (totalTime > 0 && !exit) {
+ if (eventIterator == null || !eventIterator.hasNext()) {
+ try {
+ eventSet = debugee.VM().eventQueue().remove(totalTime);
+ } catch (InterruptedException e) {
+ new Failure(e);
+ }
+ if (eventSet != null) {
+ eventIterator = eventSet.eventIterator();
+ } else {
+ eventIterator = null;
+ }
+ }
+ if (eventIterator != null) {
+ while (eventIterator.hasNext()) {
+ event = eventIterator.nextEvent();
+// display(" event ===>>> " + event);
+
+ if (event instanceof MethodEntryEvent) {
+ display(" event ===>>> " + event);
+ hitMethodBreakpoint((MethodEntryEvent )event);
+ if (eventCount > 0) {
+ exit = true;
+ evm.deleteEventRequest(mthdReq);
+ }
+ debugee.resume();
+
+ } else if (event instanceof VMDeathEvent) {
+ exit = true;
+ break;
+ } else if (event instanceof VMDisconnectEvent) {
+ exit = true;
+ break;
+ } // if
+ } // while
+ } // if
+ tmp = System.currentTimeMillis();
+ delta = tmp - begin;
+ totalTime -= delta;
+ begin = tmp;
+ }
+
+ if (totalTime <= 0 && !exit) {
+ complain("out of wait time...");
+ exitStatus = Consts.TEST_FAILED;
+ }
+ if (eventCount < expectedEventCount) {
+ complain("expecting " + expectedEventCount
+ + " breakpoint events, but "
+ + eventCount + " events arrived.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ display("=============");
+ display("TEST FINISHES\n");
+ }
+
+ private void hitMethodBreakpoint(MethodEntryEvent event) {
+ ThreadReference thrd = event.thread();
+
+ display("event info:");
+ display("\tthread\t- " + event.thread().name());
+ try {
+ display("\tsource\t- " + event.location().sourceName());
+ } catch (AbsentInformationException e) {
+ }
+ display("\tmethod\t- " + event.location().method().name());
+ display("\tline\t- " + event.location().lineNumber());
+
+ if (!event.method().name().equals(methodName)) {
+ display("the event skipped, method - " + event.method().name());
+ } else {
+ if (event.location().lineNumber() == tc05x001a.checkLastLine) {
+ display("MethodBreakpoint stops on the expected line "
+ + event.location().lineNumber() + " in method "
+ + event.method().name());
+ } else {
+ complain("MethodBreakpoint stops on line " + event.location().lineNumber()
+ + " in method " + event.method().name()
+ + ", expected line number is "
+ + tc05x001a.checkLastLine);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ eventCount++;
+ }
+ display("");
+
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc05x001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc05x001/TestDescription.java
new file mode 100644
index 00000000000..d3eec2e4013
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc05x001/TestDescription.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BScenarios/singlethrd/tc05x001.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * This test is from the group of so-called Borland's scenarios and
+ * implements the following test case:
+ * Suite 2 - Breakpoints (multiple threads)
+ * Test case: TC2
+ * Description: Class breakpoint
+ * Steps: 1.Add class breakpoint: singlethread.Class1
+ * 2.Debug Main
+ * X. Stops on line 13 in Class1.java
+ * The description was drown up according to steps under JBuilder.
+ * Of course, the test has own line numbers and method/class names and
+ * works as follow:
+ * When the test is starting debugee, debugger creates MethodEntryRequest.
+ * After MethodEntryEvent arrived, debugger checks line number of one's
+ * location. It should be 73th line, that is constructor of tc02x001aClass1
+ * class. Every thread must generate MethodEntryEvent.
+ * In case, when at least one event doesn't arrive during waittime
+ * interval or line number of event is wrong, test fails.
+ * COMMENTS:
+ * There are a doublness of the "class breakpoint" understanding.
+ * Here is that JBuilder help says:
+ * 1. "A class breakpoint causes the debugger to stop when any method
+ * from the specified class is called or when the specified class
+ * is instantiated."
+ * So, a class breakpoint is MethodEntryRequest with filtering
+ * the specified class.
+ * 2. "A class breakpoint causes the debugger to stop at the location
+ * when the specified class is loaded or when any method from the
+ * specified class is called."
+ * In this case, a class breakpoint is MethodEntryRequest and
+ * ClassPrepareRequest with filtering the specified class.
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * - quit on VMDeathEvent was added to the event handling loop
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BScenarios.singlethrd.tc05x001
+ * nsk.jdi.BScenarios.singlethrd.tc05x001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BScenarios.singlethrd.tc05x001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc05x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc05x001a.java
new file mode 100644
index 00000000000..534618176a5
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/singlethrd/tc05x001a.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.BScenarios.singlethrd;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * tc05x001a is deugee's part of the tc02x001.
+ */
+public class tc05x001a {
+
+ public final static String brkpMethodName = "performTest";
+ public final static int brkpLineNumber = 1;
+
+ public final static int checkLastLine = 82;
+ static Log log;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(tc05x001.SGL_READY);
+
+ tc05x001a obj = null;
+ String instr;
+ do {
+ instr = pipe.readln();
+ if (instr.equals(tc05x001.SGL_PERFORM)) {
+ performTest();
+ } else if (instr.equals(tc05x001.SGL_QUIT)) {
+ log.display(instr);
+ break;
+ } else {
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ } while (true);
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void performTest() {
+ log.display("performTest::creating tc05x001aClass1 object");
+ tc05x001aClass1 obj = new tc05x001aClass1();
+ log.display("performTest::invoking tc05x001aClass1.bar()");
+ obj.bar();
+ }
+}
+
+class tc05x001aClass1 {
+
+ tc05x001aClass1() {
+ tc05x001a.log.display("tc05x001aClass1::constructor is called");
+ }
+
+ public void bar() {
+ tc05x001a.log.display("tc05x001aClass1.bar::" // checkLastLine
+ + "method breakpoint should stop here");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanArgument/booleanValue/booleanvalue001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanArgument/booleanValue/booleanvalue001.java
new file mode 100644
index 00000000000..abf880997ce
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanArgument/booleanValue/booleanvalue001.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2000, 2018, 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.
+ */
+
+package nsk.jdi.BooleanArgument.booleanValue;
+
+import java.io.PrintStream;
+import java.io.Serializable;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.List;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import com.sun.jdi.VirtualMachineManager;
+import com.sun.jdi.Bootstrap;
+import com.sun.jdi.connect.Connector;
+import com.sun.jdi.connect.Connector.Argument;
+import com.sun.jdi.connect.Connector.BooleanArgument;
+import com.sun.jdi.connect.LaunchingConnector;
+
+
+/**
+ * The test for the implementation of an object of the type com.sun.jdi.connect.Connector.BooleanArgument.BooleanValue() com.sun.jdi.connect.Connector.BooleanArgument.BooleanValue() com.sun.jdi.connect.Connector.BooleanArgument.isValid() com.sun.jdi.connect.Connector.BooleanArgument.isValid() com.sun.jdi.connect.Connector.BooleanArgument.setValue() com.sun.jdi.connect.Connector.BooleanArgument.setValue() com.sun.jdi.connect.Connector.BooleanArgument.stringValueOf() com.sun.jdi.BooleanValue.equals() null.PerformComparing
+ * method.PerformComparing is static field of testedObj,execTest readsPerformComparing for each of them.equals002a is deugee's part of the test.ClassToCheck delivers values for first parameter of equals.com.sun.jdi.BooleanValue.hashCode() com.sun.jdi.BooleanValue.value() BreakpointRequests,
+ * and then it verifies that appropriate events are generated by
+ * the target VM. After that the debugger removes the requests by
+ * deleteAllBreakpoints() call. Finally, the test checks
+ * that the events corresponding to the deleted requests, are not
+ * generated by the target VM any more.
+ */
+public class breakpoint002 {
+ public static final int PASSED = 0;
+ public static final int FAILED = 2;
+ public static final int JCK_STATUS_BASE = 95;
+ static final String DEBUGGEE_CLASS =
+ "nsk.jdi.BreakpointEvent._itself_.breakpoint002t";
+ static final String COMMAND_READY = "ready";
+ static final String COMMAND_QUIT = "quit";
+
+ static final int BPS_NUM = 4;
+ static final String COMMAND_RUN[] = {
+ "run1", "run2", "run3", "run4"
+ };
+ static final int DEBUGGEE_LNS[] = {
+ 76, 79, 82, 85
+ };
+ private volatile int eventCount[] = {
+ 0, 0, 0, 0
+ };
+
+ private ArgumentHandler argHandler;
+ private Log log;
+ private IOPipe pipe;
+ private Debugee debuggee;
+ private VirtualMachine vm;
+ private EventListener elThread;
+ private volatile BreakpointRequest bpRequest[];
+ private volatile int tot_res = PASSED;
+
+// for notification a main thread about received events
+ private Object gotEvent = new Object();
+
+ public static void main (String argv[]) {
+ System.exit(run(argv,System.out) + JCK_STATUS_BASE);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+ return new breakpoint002().runIt(argv, out);
+ }
+
+ private int runIt(String args[], PrintStream out) {
+ argHandler = new ArgumentHandler(args);
+ log = new Log(out, argHandler);
+ Binder binder = new Binder(argHandler, log);
+ ReferenceType rType;
+ String cmd;
+
+ debuggee = binder.bindToDebugee(DEBUGGEE_CLASS);
+ pipe = debuggee.createIOPipe();
+ debuggee.redirectStderr(log, "breakpoint002t.err> ");
+ vm = debuggee.VM();
+ EventRequestManager erManager = vm.eventRequestManager();
+ debuggee.resume();
+ cmd = pipe.readln();
+ if (!cmd.equals(COMMAND_READY)) {
+ log.complain("TEST BUG: unknown debuggee's command: "
+ + cmd);
+ tot_res = FAILED;
+ return quitDebuggee();
+ }
+
+// Create testing requests
+ if ((rType = debuggee.classByName(DEBUGGEE_CLASS)) == null) {
+ log.complain("TEST FAILED: Method Debugee.classByName() returned null");
+ tot_res = FAILED;
+ return quitDebuggee();
+ }
+ if (createRequests(erManager, rType) == FAILED) {
+ tot_res = FAILED;
+ return quitDebuggee();
+ }
+
+// Create a thread listening JDI events
+ elThread = new EventListener();
+ elThread.setPriority(Thread.NORM_PRIORITY + 2);
+ synchronized(gotEvent) {
+ elThread.start();
+
+// Check all requested BreakpointEvents
+ for (int i=0; iaddThreadFilter, addInstanceFilter null argument value.
+ * In any cases NullPointerException is expected.
+ */
+public class filters001 {
+
+ private final static String prefix = "nsk.jdi.BreakpointRequest._bounds_.";
+ private final static String debuggerName = prefix + "filters001";
+ private final static String debugeeName = debuggerName + "a";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static String classToCheck = prefix + filters001a.classToCheck;
+ private static String indent = " : ";
+
+ private static void display(String msg) {
+ log.display("debugger> " + msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ filters001 thisTest = new filters001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ thisTest.execTest();
+ display("execTest finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() {
+
+ ReferenceType debugeeRef = debugee.classByName(debugeeName);
+ ReferenceType checkedClsRef = debugee.classByName(classToCheck);
+
+ display("");
+ display(">>>" + filters001a.objName);
+ display("----------------------");
+ Field field = debugeeRef.fieldByName(filters001a.objName);
+ Value val = debugeeRef.getValue(field);
+
+ BreakpointRequest request = debugee.setBreakpoint(checkedClsRef,
+ filters001a.brkptMethodName,
+ filters001a.brkptLineNumber);
+
+ display("");
+ addThreadFilter(request, (ThreadReference )val);
+ display("");
+ addInstanceFilter(request, (ObjectReference )val);
+
+ display("");
+ debugee.quit();
+ }
+
+ private void addThreadFilter(BreakpointRequest request, ThreadReference thread) {
+
+ display("addThreadFilter :ThreadReference> null");
+ try {
+ request.addThreadFilter(thread);
+ complain("*****NullPointerException is not thrown");
+ exitStatus = Consts.TEST_FAILED;
+ } catch (NullPointerException e) {
+ display("!!!Expected " + e);
+ } catch (Exception e) {
+ complain("*****Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ }
+
+ private void addInstanceFilter(BreakpointRequest request,
+ ObjectReference instance) {
+
+ display("addInstanceFilter :ObjectReference> null");
+
+ try {
+ request.addInstanceFilter(instance);
+ complain("*****NullPointerException is not thrown");
+ exitStatus = Consts.TEST_FAILED;
+ } catch (NullPointerException e) {
+ display("!!!Expected " + e);
+ } catch (Exception e) {
+ complain("*****Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/_bounds_/filters001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/_bounds_/filters001/TestDescription.java
new file mode 100644
index 00000000000..cee61e10abf
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/_bounds_/filters001/TestDescription.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BreakpointRequest/_bounds_/filters001.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the boundary value of the parameters.
+ * The test checks up that the methods
+ * com.sun.jdi.request.BreakpointRequest.addThreadFilter(ThreadReference)
+ * com.sun.jdi.request.BreakpointRequest.addInstanceFilter(ObjectReference)
+ * correctly work for the boundary value of parameter and throw described
+ * exceptions.
+ * The test check up this methods with filters001a is deugee's part of the test.
+ */
+public class filters001a {
+
+ static String classToCheck = "filters001b";
+ static String objName = "testedObjNULL";
+ static filters001b testedObjNULL = null;
+
+ static final String brkptMethodName = "run";
+ static final int brkptLineNumber = 75;
+
+ public static void main (String argv[]) {
+
+ // create temporary object to load com.sun.jdi.BreakpointRequest.addInstanceFilter()
+ * complies with its spec.
+ *
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those
+ * in which the currently executing instance is
+ * the object specified.
+ *
+ * The test works as follows.
+ * - The debugger resumes the debuggee and waits for the BreakpointEvent.
+ * - The debuggee creates a special array with three Object instances,
+ * and two threads, thread1 and thread2, and invokes
+ * the methodForCommunication to be suspended and
+ * to inform the debugger with the event.
+ * - Upon getting the BreakpointEvent, the debugger
+ * - sets up a BreakpointRequest
+ * within the method in the class TestClass
+ * whose array element instances #0 and #1
+ * will be calling by the thread1 and the thread2 accordinly,
+ * - invokes addInstanceFilter() on array element #0 for the thread1
+ * and #2 for the thread2,
+ * thus restricting the breakpoint event only for thread1,
+ * - resumes debuggee's main thread, and
+ * - waits for the event.
+ * - Debuggee's main thread starts both threads.
+ * - Upon getting the event, the debugger performs the checks required.
+ */
+
+public class instancefilter001 extends TestDebuggerType1 {
+
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ debuggeeName = "nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter001a";
+ return new instancefilter001().runThis(argv, out);
+ }
+
+ private String testedClassName =
+ "nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter001aTestClass";
+
+
+ protected void testRun() {
+ if ( !vm.canUseInstanceFilters() ) {
+ display("......vm.canUseInstanceFilters == false :: test cancelled");
+ vm.exit(Consts.JCK_STATUS_BASE);
+ return;
+ }
+
+ EventRequest eventRequest1 = null;
+ EventRequest eventRequest2 = null;
+
+ ThreadReference thread1 = null;
+ ThreadReference thread2 = null;
+
+ String thread1Name = "thread1";
+ String thread2Name = "thread2";
+
+ String property1 = "BreakpointRequest1";
+ String property2 = "BreakpointRequest2";
+
+ String methodName = "method";
+ String bpLineName = "breakpointLine";
+
+ ReferenceType testClassReference = null;
+
+ String arrayName = "objTC";
+ ObjectReference instance = null;
+ Event newEvent = null;
+
+ for (int i = 0; ; i++) {
+
+ if (!shouldRunAfterBreakpoint()) {
+ vm.resume();
+ break;
+ }
+
+ display(":::::: case: # " + i);
+
+ switch (i) {
+
+ case 0:
+ testClassReference =
+ (ReferenceType) vm.classesByName(testedClassName).get(0);
+
+ thread1 = (ThreadReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(thread1Name));
+ thread2 = (ThreadReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(thread2Name));
+
+ eventRequest1 = setting2BreakpointRequest (thread1,
+ testClassReference, methodName, bpLineName,
+ EventRequest.SUSPEND_ALL, property1);
+
+ instance = (ObjectReference)
+ ((ArrayReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(arrayName)) ).getValue(0);
+
+ ((BreakpointRequest) eventRequest1).addInstanceFilter(instance);
+
+ eventRequest2 = setting2BreakpointRequest (thread2,
+ testClassReference, methodName, bpLineName,
+ EventRequest.SUSPEND_ALL, property2);
+
+ instance = (ObjectReference)
+ ((ArrayReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(arrayName)) ).getValue(2);
+
+ ((BreakpointRequest) eventRequest2).addInstanceFilter(instance);
+
+ display("......waiting for BreakpointEvent in expected thread");
+ newEvent = eventHandler.waitForRequestedEvent(new EventRequest[]{eventRequest1, eventRequest2}, waitTime, true);
+
+ if ( !(newEvent instanceof BreakpointEvent)) {
+ setFailedStatus("ERROR: new event is not BreakpointEvent");
+ } else {
+
+ String property = (String) newEvent.request().getProperty("number");
+ display(" got new BreakpointEvent with propety 'number' == " + property);
+
+ if ( !property.equals(property1) ) {
+ setFailedStatus("ERROR: property is not : " + property1);
+ }
+ }
+ vm.resume();
+ break;
+
+ default:
+ throw new Failure("** default case 2 **");
+ }
+ }
+ return;
+ }
+
+ private BreakpointRequest setting2BreakpointRequest ( ThreadReference thread,
+ ReferenceType testedClass,
+ String methodName,
+ String bpLine,
+ int suspendPolicy,
+ String property ) {
+ try {
+ display("......setting up a breakpoint:");
+ display(" thread: " + thread + "; class: " + testedClass + "; method: " + methodName + "; line: " + bpLine);
+
+ int n = ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value();
+ Location loc = (Location) ((Method) testedClass.methodsByName(methodName).get(0)).allLineLocations().get(n);
+
+ BreakpointRequest
+ bpr = eventRManager.createBreakpointRequest(loc);
+ bpr.putProperty("number", property);
+ if (thread != null)
+ bpr.addThreadFilter(thread);
+ bpr.setSuspendPolicy(suspendPolicy);
+
+ display(" a breakpoint has been set up");
+ return bpr;
+ } catch ( Exception e ) {
+ throw new Failure("** FAILURE to set up BreakpointRequest **");
+ }
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001/TestDescription.java
new file mode 100644
index 00000000000..f580dae4b92
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001/TestDescription.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the implementation of an object of the type
+ * BreakpointRequest.
+ * The test checks up that a result of the method
+ * com.sun.jdi.BreakpointRequest.addInstanceFilter()
+ * complies with its spec:
+ * public void addInstanceFilter(ObjectReference instance)
+ * Restricts the events generated by this request to those in which
+ * the currently executing instance is the object specified.
+ * Not all targets support this operation.
+ * Use VirtualMachine.canUseInstanceFilters() to determine
+ * if the operation is supported.
+ * Parameters: instance - the object which must be the current instance
+ * in order to pass this filter.
+ * Throws: UnsupportedOperationException -
+ * if the target virtual machine does not support this operation.
+ * InvalidRequestStateException -
+ * if this request is currently enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those in which
+ * the currently executing instance is the object specified.
+ * The test works as follows:
+ * The debugger program - nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter001;
+ * the debuggee program - nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter001a.
+ * Using nsk.jdi.share classes,
+ * the debugger gets the debuggee running on another JavaVM,
+ * creates the object debuggee.VM, and waits for VMStartEvent.
+ * Upon getting the debuggee VM started,
+ * the debugger calls corresponding debuggee.VM methods to get
+ * needed data and to perform checks.
+ * In case of error the test produces the return value 97 and
+ * a corresponding error message(s).
+ * Otherwise, the test is passed and produces
+ * the return value 95 and no message.
+ * COMMENTS:
+ * 4930911 TEST_BUG: filter_rt006 debuggee has a race
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter001
+ * nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001a.java
new file mode 100644
index 00000000000..3569a345786
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001a.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.BreakpointRequest.addInstanceFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * This class is used as debuggee application for the instancefilter001 JDI test.
+ */
+
+public class instancefilter001a {
+
+ //----------------------------------------------------- templete section
+
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ static ArgumentHandler argHandler;
+ static Log log;
+
+ //-------------------------------------------------- log procedures
+
+ private static void log1(String message) {
+ log.display("**> debuggee: " + message);
+ }
+
+ private static void logErr(String message) {
+ log.complain("**> debuggee: " + message);
+ }
+
+ //====================================================== test program
+
+ static Threadinstancefilter001a thread1 = null;
+ static Threadinstancefilter001a thread2 = null;
+
+ static instancefilter001aTestClass objTC[] = { new instancefilter001aTestClass(), new instancefilter001aTestClass(), new instancefilter001aTestClass() };
+
+ //------------------------------------------------------ common section
+
+ static int exitCode = PASSED;
+
+ static int instruction = 1;
+ static int end = 0;
+ // static int quit = 0;
+ // static int continue = 2;
+ static int maxInstr = 1; // 2;
+
+ static int lineForComm = 2;
+
+ private static void methodForCommunication() {
+ int i1 = instruction;
+ int i2 = i1;
+ int i3 = i2;
+ }
+ //---------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+
+ argHandler = new ArgumentHandler(argv);
+ log = argHandler.createDebugeeLog();
+
+ log1("debuggee started!");
+
+ label0:
+ for (int i = 0; ; i++) {
+
+ if (instruction > maxInstr) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break ;
+ }
+
+ switch (i) {
+
+ //------------------------------------------------------ section tested
+
+ case 0:
+ thread1 = new Threadinstancefilter001a("thread1");
+ thread2 = new Threadinstancefilter001a("thread2");
+ break;
+
+ case 1:
+ threadStart(thread1);
+ threadStart(thread2);
+ synchronized(lockingObj[0]) {
+ log1("main: synchronized(lockingObj[0])");
+ }
+ synchronized(lockingObj[1]) {
+ log1("main: synchronized(lockingObj[1])");
+ }
+
+ //------------------------------------------------- standard end section
+
+ default:
+ instruction = end;
+ break;
+ }
+ log1("methodForCommunication();");
+ methodForCommunication();
+ if (instruction == end)
+ break;
+ }
+
+ log1("debuggee exits");
+ System.exit(exitCode + PASS_BASE);
+ }
+
+
+ static Object waitnotifyObj = new Object();
+
+ static int threadStart(Thread t) {
+ synchronized (waitnotifyObj) {
+ t.start();
+ try {
+ waitnotifyObj.wait();
+ } catch ( Exception e) {
+ exitCode = FAILED;
+ logErr(" Exception : " + e );
+ return FAILED;
+ }
+ }
+ return PASSED;
+ }
+
+ static Object lockingObj[] = new Object[2];
+ static volatile int number = 0;
+
+ static class Threadinstancefilter001a extends Thread {
+
+ String tName = null;
+ int tNumber;
+
+ public Threadinstancefilter001a(String threadName) {
+ super(threadName);
+ tName = threadName;
+ tNumber = number;
+ number++;
+ lockingObj[tNumber] = threadName;
+ }
+
+ public void run() {
+ log1(" 'run': enter :: threadName == " + tName);
+ if (lockingObj[tNumber] == null)
+ log1("lockingObj[tNumber] == null");
+ synchronized(lockingObj[tNumber]) {
+ synchronized (waitnotifyObj) {
+ waitnotifyObj.notify();
+ }
+ log1(" objTC[tNumber].method(); :: threadName == " + tName + " tNumber == " + tNumber);
+ objTC[tNumber].method();
+ }
+ log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+ }
+
+}
+
+class instancefilter001aTestClass {
+
+ static int breakpointLine = 3;
+
+ static int var1 = 0;
+ static int var2 = 0;
+ static int var3 = 0;
+
+ public void method () {
+ var1 = 1;
+ var3 = var1;
+ var2 = var3;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java
new file mode 100644
index 00000000000..cbc2b30f939
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java
@@ -0,0 +1,559 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.BreakpointRequest.addInstanceFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type com.sun.jdi.BreakpointRequest.addInstanceFilter()com.sun.jdi.BreakpointRequest.addInstanceFilter()com.sun.jdi.BreakpointRequest.addInstanceFilter()
+ * complies with its spec.
+ *
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those in which
+ * the currently executing instance is the object specified.
+ * The cases to test includes re-invocation of the method
+ * addInstanceFilter() on the same BreakpointRequest object.
+ * There are two BreakpointRequests to check as follows:
+ * (1) For BreakpointRequest2, both invocations are with different
+ * ObjectReferences restricting one Breakpoint event to two objects.
+ * The test expects no Breakpoint event will be received.
+ * (2) For BreakpointRequest1, both invocations are with the same
+ * ObjectReference restricting one Breakpoint event to one object.
+ * The test expects this Breakpoint event will be received.
+ *
+ * The test works as follows.
+ * - The debugger resumes the debuggee and waits for the BreakpointEvent.
+ * - The debuggee creates two threads, thread1 and thread2,
+ * an array with three instances of the TestClass containing a method
+ * calling by both threads, and invokes
+ * the methodForCommunication to be suspended and
+ * to inform the debugger with the event.
+ * - Upon getting the BreakpointEvent, the debugger
+ * - sets up BreakpointRequests 1&2 within the method
+ * in the class TestClass which will be calling by both threads,
+ * - restricts the BreakpointRequest1 to the tread1 and
+ * to the array elements #0 & #0 calling only within thread1,
+ * - restricts the BreakpointRequest2 to the thread2 and
+ * the array elements #0 & #1 calling within thread1 and thread2,
+ * - resumes debuggee's main thread, and
+ * - waits for the event.
+ * - Debuggee's main thread starts both threads.
+ * - Upon getting the event, the debugger performs the checks required.
+ */
+
+public class instancefilter004 extends TestDebuggerType1 {
+
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ debuggeeName = "nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter004a";
+ return new instancefilter004().runThis(argv, out);
+ }
+
+ private String testedClassName =
+ "nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter004aTestClass";
+
+ protected void testRun() {
+ if ( !vm.canUseInstanceFilters() ) {
+ display("......vm.canUseInstanceFilters == false :: test cancelled");
+ vm.exit(Consts.JCK_STATUS_BASE);
+ return;
+ }
+
+ EventRequest eventRequest1 = null;
+ EventRequest eventRequest2 = null;
+
+ ThreadReference thread1 = null;
+ ThreadReference thread2 = null;
+
+ String thread1Name = "thread1";
+ String thread2Name = "thread2";
+
+ String property1 = "BreakpointRequest1";
+ String property2 = "BreakpointRequest2";
+
+ String methodName = "method";
+ String bpLineName = "breakpointLine";
+
+ ReferenceType testClassReference = null;
+
+ String arrayName = "objTC";
+
+ ObjectReference instance1 = null;
+ ObjectReference instance2 = null;
+
+ for (int i = 0; ; i++) {
+
+ if (!shouldRunAfterBreakpoint()) {
+ vm.resume();
+ break;
+ }
+
+ display(":::::: case: # " + i);
+
+ switch (i) {
+
+ case 0:
+ testClassReference =
+ (ReferenceType) vm.classesByName(testedClassName).get(0);
+
+ thread1 = (ThreadReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(thread1Name));
+ thread2 = (ThreadReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(thread2Name));
+
+ eventRequest1 = setting2BreakpointRequest (thread1,
+ testClassReference, methodName, bpLineName,
+ EventRequest.SUSPEND_ALL, property1);
+ eventRequest2 = setting2BreakpointRequest (thread2,
+ testClassReference, methodName, bpLineName,
+ EventRequest.SUSPEND_ALL, property2);
+
+ instance1 = (ObjectReference)
+ ((ArrayReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(arrayName)) ).getValue(0);
+ instance2 = (ObjectReference)
+ ((ArrayReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(arrayName)) ).getValue(1);
+
+ ((BreakpointRequest) eventRequest1).addInstanceFilter(instance1);
+ ((BreakpointRequest) eventRequest1).addInstanceFilter(instance1);
+ ((BreakpointRequest) eventRequest2).addInstanceFilter(instance1);
+ ((BreakpointRequest) eventRequest2).addInstanceFilter(instance2);
+
+ display("......waiting for BreakpointEvent in expected thread");
+ BreakpointEvent newEvent = (BreakpointEvent)eventHandler.waitForRequestedEvent(new EventRequest[]{eventRequest1, eventRequest2}, waitTime, true);
+
+ EventRequest newEventRequest = newEvent.request();
+ if ( newEventRequest.equals(eventRequest1) ) {
+ display(" received expected event: " + newEvent);
+
+ ThreadReference newEventThread = newEvent.thread();
+ String threadName = newEventThread.name();
+ display(" the event is in thread == " + newEventThread.name());
+ if ( !newEventThread.equals(thread1) ) {
+ setFailedStatus("ERROR: the event is not in thread1");
+ }
+ }
+ vm.resume();
+ break;
+
+ default:
+ throw new Failure("** default case 2 **");
+ }
+ }
+ return;
+ }
+
+ private BreakpointRequest setting2BreakpointRequest ( ThreadReference thread,
+ ReferenceType testedClass,
+ String methodName,
+ String bpLine,
+ int suspendPolicy,
+ String property ) {
+ try {
+ display("......setting up a breakpoint:");
+ display(" thread: " + thread + "; class: " + testedClass + "; method: " + methodName + "; line: " + bpLine);
+
+ int n = ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value();
+ Location loc = (Location) ((Method) testedClass.methodsByName(methodName).get(0)).allLineLocations().get(n);
+
+ BreakpointRequest
+ bpr = eventRManager.createBreakpointRequest(loc);
+ bpr.putProperty("number", property);
+ if (thread != null)
+ bpr.addThreadFilter(thread);
+ bpr.setSuspendPolicy(suspendPolicy);
+
+ display(" a breakpoint has been set up");
+ return bpr;
+ } catch ( Exception e ) {
+ throw new Failure("** FAILURE to set up BreakpointRequest **");
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004/TestDescription.java
new file mode 100644
index 00000000000..30615643833
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004/TestDescription.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the implementation of an object of the type
+ * BreakpointRequest.
+ * The test checks up that a result of the method
+ * com.sun.jdi.BreakpointRequest.addInstanceFilter()
+ * complies with its spec:
+ * public void addInstanceFilter(ObjectReference instance)
+ * Restricts the events generated by this request to those in which
+ * the currently executing instance is the object specified.
+ * Not all targets support this operation.
+ * Use VirtualMachine.canUseInstanceFilters() to determine
+ * if the operation is supported.
+ * Parameters: instance - the object which must be the current instance
+ * in order to pass this filter.
+ * Throws: UnsupportedOperationException -
+ * if the target virtual machine does not support this operation.
+ * InvalidRequestStateException -
+ * if this request is currently enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those in which
+ * the currently executing instance is the object specified.
+ * The cases to test includes re-invocation of the method
+ * addInstanceFilter() on the same BreakpointRequest object.
+ * There are two BreakpointRequests to check as follows:
+ * (1) For BreakpointRequest2, both invocations are with different
+ * ObjectReferences restricting one Breakpoint event to two objects.
+ * The test expects no Breakpoint event will be received.
+ * (2) For BreakpointRequest1, both invocations are with the same
+ * ObjectReference restricting one Breakpoint event to one object.
+ * The test expects this Breakpoint event will be received.
+ * The test works as follows:
+ * The debugger program - nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter004;
+ * the debuggee program - nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter004a.
+ * Using nsk.jdi.share classes,
+ * the debugger gets the debuggee running on another JavaVM,
+ * creates the object debuggee.VM, and waits for VMStartEvent.
+ * Upon getting the debuggee VM started,
+ * the debugger calls corresponding debuggee.VM methods to get
+ * needed data and to perform checks.
+ * In case of error the test produces the return value 97 and
+ * a corresponding error message(s).
+ * Otherwise, the test is passed and produces
+ * the return value 95 and no message.
+ * COMMENTS:
+ * 4930911 TEST_BUG: filter_rt006 debuggee has a race
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter004
+ * nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter004a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter004
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004a.java
new file mode 100644
index 00000000000..b30041b0ac1
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004a.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.BreakpointRequest.addInstanceFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * This class is used as debuggee application for the instancefilter004 JDI test.
+ */
+
+public class instancefilter004a {
+
+ //----------------------------------------------------- templete section
+
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ static ArgumentHandler argHandler;
+ static Log log;
+
+ //-------------------------------------------------- log procedures
+
+ private static void log1(String message) {
+ log.display("**> debuggee: " + message);
+ }
+
+ private static void logErr(String message) {
+ log.complain("**> debuggee: " + message);
+ }
+
+ //====================================================== test program
+
+ static Threadinstancefilter004a thread1 = null;
+ static Threadinstancefilter004a thread2 = null;
+
+ static instancefilter004aTestClass objTC[] = { new instancefilter004aTestClass(), new instancefilter004aTestClass(), new instancefilter004aTestClass() };
+
+ //------------------------------------------------------ common section
+
+ static int exitCode = PASSED;
+
+ static int instruction = 1;
+ static int end = 0;
+ // static int quit = 0;
+ // static int continue = 2;
+ static int maxInstr = 1; // 2;
+
+ static int lineForComm = 2;
+
+ private static void methodForCommunication() {
+ int i1 = instruction;
+ int i2 = i1;
+ int i3 = i2;
+ }
+ //---------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+
+ argHandler = new ArgumentHandler(argv);
+ log = argHandler.createDebugeeLog();
+
+ log1("debuggee started!");
+
+ label0:
+ for (int i = 0; ; i++) {
+
+ if (instruction > maxInstr) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break ;
+ }
+
+ switch (i) {
+
+ //------------------------------------------------------ section tested
+
+ case 0:
+ thread1 = new Threadinstancefilter004a("thread1");
+ thread2 = new Threadinstancefilter004a("thread2");
+ break;
+
+ case 1:
+ threadStart(thread1);
+ threadStart(thread2);
+ synchronized(lockingObj[0]) {
+ log1("main: synchronized(lockingObj[0])");
+ }
+ synchronized(lockingObj[1]) {
+ log1("main: synchronized(lockingObj[1])");
+ }
+
+ //------------------------------------------------- standard end section
+
+ default:
+ instruction = end;
+ break;
+ }
+ log1("methodForCommunication();");
+ methodForCommunication();
+ if (instruction == end)
+ break;
+ }
+
+ log1("debuggee exits");
+ System.exit(exitCode + PASS_BASE);
+ }
+
+
+ static Object waitnotifyObj = new Object();
+
+ static int threadStart(Thread t) {
+ synchronized (waitnotifyObj) {
+ t.start();
+ try {
+ waitnotifyObj.wait();
+ } catch ( Exception e) {
+ exitCode = FAILED;
+ logErr(" Exception : " + e );
+ return FAILED;
+ }
+ }
+ return PASSED;
+ }
+
+ static Object lockingObj[] = new Object[2];
+ static volatile int number = 0;
+
+ static class Threadinstancefilter004a extends Thread {
+
+ String tName = null;
+ int tNumber;
+
+ public Threadinstancefilter004a(String threadName) {
+ super(threadName);
+ tName = threadName;
+ tNumber = number;
+ number++;
+ lockingObj[tNumber] = threadName;
+ }
+
+ public void run() {
+ log1(" 'run': enter :: threadName == " + tName);
+ if (lockingObj[tNumber] == null)
+ log1("lockingObj[tNumber] == null");
+ synchronized(lockingObj[tNumber]) {
+ synchronized (waitnotifyObj) {
+ waitnotifyObj.notify();
+ }
+ log1(" objTC[tNumber].method(); :: threadName == " + tName + " tNumber == " + tNumber);
+ objTC[tNumber].method();
+ }
+ log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+ }
+
+}
+
+class instancefilter004aTestClass {
+
+ static int breakpointLine = 3;
+
+ static int var1 = 0;
+ static int var2 = 0;
+ static int var3 = 0;
+
+ public void method () {
+ var1 = 1;
+ var3 = var1;
+ var2 = var3;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001.java
new file mode 100644
index 00000000000..7205550f17c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.BreakpointRequest.addThreadFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type
+ * BreakpointRequest.
+ *
+ * The test checks that results of the method
+ * com.sun.jdi.BreakpointRequest.addThreadFilter()
+ * complies with its spec.
+ *
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request
+ * to those in the given thread.
+ *
+ * The test works as follows.
+ *
+ * - The debugger resumes the debuggee and waits for the BreakpointEvent.
+ * - The debuggee creates two threads, thread1 and thread2, and invokes
+ * the methodForCommunication to be suspended and
+ * to inform the debugger with the event.
+ * - Upon getting the BreakpointEvent, the debugger
+ * - sets up a BreakpointRequest within the method
+ * in the class TestClass which will be calling by both threads,
+ * - restricts the breakpoint event only for thread1,
+ * - resumes debuggee's main thread, and
+ * - waits for the event.
+ * - Debuggee's main thread starts both threads.
+ * - Upon getting the event, the debugger performs the checks required.
+ */
+
+public class threadfilter001 extends TestDebuggerType1 {
+
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ debuggeeName = "nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter001a";
+ return new threadfilter001().runThis(argv, out);
+ }
+
+ private String testedClassName =
+ "nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter001aTestClass";
+
+ protected void testRun() {
+
+ EventRequest eventRequest1 = null;
+ ThreadReference thread1 = null;
+ String thread1Name = "thread1";
+ String property1 = "BreakpointRequest1";
+ String methodName = "method";
+ String bpLineName = "breakpointLine";
+ ReferenceType testClassReference = null;
+
+ for (int i = 0; ; i++) {
+
+ if (!shouldRunAfterBreakpoint()) {
+ vm.resume();
+ break;
+ }
+
+ display(":::::: case: # " + i);
+
+ switch (i) {
+
+ case 0:
+ testClassReference =
+ (ReferenceType) vm.classesByName(testedClassName).get(0);
+
+ thread1 = (ThreadReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(thread1Name));
+
+ eventRequest1 = setting2BreakpointRequest (thread1,
+ testClassReference, methodName, bpLineName,
+ EventRequest.SUSPEND_ALL, property1);
+
+ display("......waiting for BreakpointEvent in tested thread");
+
+ Event newEvent = eventHandler.waitForRequestedEvent(new EventRequest[]{eventRequest1}, waitTime, true);
+ if ( !(newEvent instanceof BreakpointEvent)) {
+ setFailedStatus("ERROR: new event is not BreakpointEvent");
+ } else {
+ String property = (String) newEvent.request().getProperty("number");
+ display(" got new BreakpointEvent with property 'number' == " + property);
+
+ if ( !property.equals(property1) ) {
+ setFailedStatus("ERROR: property is not : " + property1);
+ }
+
+ ThreadReference thr = ((BreakpointEvent)newEvent).thread();
+ if (!thr.equals(thread1)) {
+ setFailedStatus("The BreakpointEvent occured in unexpected thread: " + thr);
+ }
+ }
+ vm.resume();
+ break;
+
+ default:
+ throw new Failure("** default case 2 **");
+ }
+ }
+ return;
+ }
+
+ private BreakpointRequest setting2BreakpointRequest ( ThreadReference thread,
+ ReferenceType testedClass,
+ String methodName,
+ String bpLine,
+ int suspendPolicy,
+ String property ) {
+ try {
+ display("......setting up a breakpoint:");
+ display(" thread: " + thread + "; class: " + testedClass + "; method: " + methodName + "; line: " + bpLine);
+
+ int n = ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value();
+ Location loc = (Location) ((Method) testedClass.methodsByName(methodName).get(0)).allLineLocations().get(n);
+
+ BreakpointRequest
+ bpr = eventRManager.createBreakpointRequest(loc);
+ bpr.putProperty("number", property);
+ if (thread != null)
+ bpr.addThreadFilter(thread);
+ bpr.setSuspendPolicy(suspendPolicy);
+
+ display(" a breakpoint has been set up");
+ return bpr;
+ } catch ( Exception e ) {
+ throw new Failure("** FAILURE to set up BreakpointRequest **");
+ }
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001/TestDescription.java
new file mode 100644
index 00000000000..54348cd43fd
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001/TestDescription.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the implementation of an object of the type
+ * BreakpointRequest.
+ * The test checks up that a result of the method
+ * com.sun.jdi.BreakpointRequest.addThreadFilter()
+ * complies with its spec:
+ * public void addThreadFilter(ThreadReference thread)
+ * Restricts the events generated by this request to those in the given thread.
+ * Parameters: thread - the thread to filter on.
+ * Throws: InvalidRequestStateException -
+ * if this request is currently enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request
+ * to those in the given thread.
+ * The test works as follows:
+ * The debugger program - nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter001;
+ * the debuggee program - nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter001a.
+ * Using nsk.jdi.share classes,
+ * the debugger gets the debuggee running on another JavaVM,
+ * creates the object debuggee.VM, and waits for VMStartEvent.
+ * Upon getting the debuggee VM started,
+ * the debugger calls corresponding debuggee.VM methods to get
+ * needed data and to perform checks.
+ * In case of error the test produces the return value 97 and
+ * a corresponding error message(s).
+ * Otherwise, the test is passed and produces
+ * the return value 95 and no message.
+ * COMMENTS:
+ * 4930911 TEST_BUG: filter_rt006 debuggee has a race
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter001
+ * nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001a.java
new file mode 100644
index 00000000000..81625b6b02f
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001a.java
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.BreakpointRequest.addThreadFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * This class is used as debuggee application for the threadfilter001 JDI test.
+ */
+
+public class threadfilter001a {
+
+ //----------------------------------------------------- templete section
+
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ static ArgumentHandler argHandler;
+ static Log log;
+
+ //-------------------------------------------------- log procedures
+
+ private static void log1(String message) {
+ log.display("**> debuggee: " + message);
+ }
+
+ private static void logErr(String message) {
+ log.complain("**> debuggee: " + message);
+ }
+
+ //====================================================== test program
+
+ static Threadthreadfilter001a thread1 = null;
+ static Threadthreadfilter001a thread2 = null;
+
+ static threadfilter001aTestClass objTC = new threadfilter001aTestClass();
+
+ //------------------------------------------------------ common section
+
+ static int exitCode = PASSED;
+
+ static int instruction = 1;
+ static int end = 0;
+ // static int quit = 0;
+ // static int continue = 2;
+ static int maxInstr = 1; // 2;
+
+ static int lineForComm = 2;
+
+ private static void methodForCommunication() {
+ int i1 = instruction;
+ int i2 = i1;
+ int i3 = i2;
+ }
+ //---------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+
+ argHandler = new ArgumentHandler(argv);
+ log = argHandler.createDebugeeLog();
+
+ log1("debuggee started!");
+
+ label0:
+ for (int i = 0; ; i++) {
+
+ if (instruction > maxInstr) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break ;
+ }
+
+ switch (i) {
+
+ //------------------------------------------------------ section tested
+
+ case 0:
+ thread1 = new Threadthreadfilter001a("thread1");
+ thread2 = new Threadthreadfilter001a("thread2");
+ break;
+
+ case 1:
+ threadStart(thread1);
+ threadStart(thread2);
+ synchronized(lockingObj[0]) {
+ log1("synchronized(lockingObj[0])");
+ }
+ synchronized(lockingObj[1]) {
+ log1("synchronized(lockingObj[1])");
+ }
+
+ //------------------------------------------------- standard end section
+
+ default:
+ instruction = end;
+ break;
+ }
+ log1("methodForCommunication();");
+ methodForCommunication();
+ if (instruction == end)
+ break;
+ }
+
+ log1("debuggee exits");
+ System.exit(exitCode + PASS_BASE);
+ }
+
+
+ static Object waitnotifyObj = new Object();
+
+ static int threadStart(Thread t) {
+ synchronized (waitnotifyObj) {
+ t.start();
+ try {
+ waitnotifyObj.wait();
+ } catch ( Exception e) {
+ exitCode = FAILED;
+ logErr(" Exception : " + e );
+ return FAILED;
+ }
+ }
+ return PASSED;
+ }
+
+ static Object lockingObj[] = new Object[2];
+ static volatile int number = 0;
+
+ static class Threadthreadfilter001a extends Thread {
+
+ String tName = null;
+ int tNumber;
+
+ public Threadthreadfilter001a(String threadName) {
+ super(threadName);
+ tName = threadName;
+ tNumber = number;
+ number++;
+ lockingObj[tNumber] = threadName;
+ }
+
+ public void run() {
+ log1(" 'run': enter :: threadName == " + tName);
+ if (lockingObj[tNumber] == null)
+ log1("lockingObj[tNumber] == null");
+ synchronized(lockingObj[tNumber]) {
+ synchronized (waitnotifyObj) {
+ waitnotifyObj.notify();
+ }
+ objTC.method();
+ }
+ log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+ }
+
+}
+
+class threadfilter001aTestClass {
+
+ static int breakpointLine = 3;
+
+ static int var1 = 0;
+ static int var2 = 0;
+ static int var3 = 0;
+
+ static void method () {
+ var1 = 1;
+ var3 = var1;
+ var2 = var3;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java
new file mode 100644
index 00000000000..79ccc79dd38
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java
@@ -0,0 +1,545 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.BreakpointRequest.addThreadFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type com.sun.jdi.BreakpointRequest.addThreadFilter() com.sun.jdi.BreakpointRequest.addThreadFilter() com.sun.jdi.BreakpointRequest.addThreadFilter()
+ * complies with its spec.
+ *
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request
+ * to those in the given thread.
+ * The cases to test include re-invocations of the method
+ * addThreadFilter() on the same BreakpointRequest object.
+ * There are two BreakpointRequests to check as follows:
+ * (1) For BreakpointRequest2, both invocations are with different
+ * ThreadReferences restricting one Breakpoint event to two threads.
+ * The test expects no Breakpoint event will be received.
+ * (2) For BreakpointRequest1, both invocations are with the same
+ * ThreadReference restricting one Breakpoint event to one thread.
+ * The test expects this Breakpoint event will be received.
+ *
+ * The test works as follows.
+ * - The debugger resumes the debuggee and waits for the BreakpointEvent.
+ * - The debuggee creates two threads, thread1 and thread2, and invokes
+ * the methodForCommunication to be suspended and
+ * to inform the debugger with the event.
+ * - Upon getting the BreakpointEvent, the debugger
+ * - sets up BreakpointRequests 1&2 within the method
+ * in the class TestClass which will be calling by both threads,
+ * - restricts the BreakpointRequest1 only to thread1,
+ * - restricts the BreakpointRequest2 to both thread1 and thread2,
+ * - resumes debuggee's main thread, and
+ * - waits for the event.
+ * - Debuggee's main thread starts both threads.
+ * - Upon getting the event, the debugger performs the checks required.
+ */
+
+public class threadfilter004 extends TestDebuggerType1 {
+
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ debuggeeName = "nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter004a";
+ return new threadfilter004().runThis(argv, out);
+ }
+
+ private String testedClassName =
+ "nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter004aTestClass";
+
+ protected void testRun() {
+
+ EventRequest eventRequest1 = null;
+ EventRequest eventRequest2 = null;
+
+ ThreadReference thread1 = null;
+ ThreadReference thread2 = null;
+
+ String thread1Name = "thread1";
+ String thread2Name = "thread2";
+
+ String property1 = "BreakpointRequest1";
+ String property2 = "BreakpointRequest2";
+
+ String methodName = "method";
+ String bpLineName = "breakpointLine";
+
+ ReferenceType testClassReference = null;
+
+ for (int i = 0; ; i++) {
+
+ if (!shouldRunAfterBreakpoint()) {
+ vm.resume();
+ break;
+ }
+
+ display(":::::: case: # " + i);
+
+ switch (i) {
+
+ case 0:
+ testClassReference =
+ (ReferenceType) vm.classesByName(testedClassName).get(0);
+
+ thread1 = (ThreadReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(thread1Name));
+ thread2 = (ThreadReference) debuggeeClass.getValue(
+ debuggeeClass.fieldByName(thread2Name));
+
+ eventRequest1 = setting2BreakpointRequest (thread1,
+ testClassReference, methodName, bpLineName,
+ EventRequest.SUSPEND_ALL, property1);
+ eventRequest2 = setting2BreakpointRequest (thread1,
+ testClassReference, methodName, bpLineName,
+ EventRequest.SUSPEND_ALL, property2);
+
+ ((BreakpointRequest) eventRequest1).addThreadFilter(thread1);
+ ((BreakpointRequest) eventRequest2).addThreadFilter(thread2);
+
+ display("......waiting for BreakpointEvent in tested thread1");
+ Event newEvent = eventHandler.waitForRequestedEvent(new EventRequest[]{eventRequest1, eventRequest2}, waitTime, true);
+
+ if ( !(newEvent instanceof BreakpointEvent)) {
+ setFailedStatus("ERROR: new event is not BreakpointEvent");
+ } else {
+ String property = (String) newEvent.request().getProperty("number");
+ display(" got new BreakpointEvent with property 'number' == " + property);
+
+ if ( !property.equals(property1) ) {
+ setFailedStatus("ERROR: property is not : " + property1);
+ }
+
+ EventRequest newEventRequest = newEvent.request();
+ if (!newEventRequest.equals(eventRequest1) ) {
+ setFailedStatus("The BreakpointEvent occured not for eventRequest1");
+ }
+
+ ThreadReference thr = ((BreakpointEvent)newEvent).thread();
+ if (!thr.equals(thread1)) {
+ setFailedStatus("The BreakpointEvent occured in unexpected thread: " + thr);
+ }
+ }
+ vm.resume();
+ break;
+
+ default:
+ throw new Failure("** default case 2 **");
+ }
+ }
+ return;
+ }
+
+ private BreakpointRequest setting2BreakpointRequest ( ThreadReference thread,
+ ReferenceType testedClass,
+ String methodName,
+ String bpLine,
+ int suspendPolicy,
+ String property ) {
+ try {
+ display("......setting up a breakpoint:");
+ display(" thread: " + thread + "; class: " + testedClass + "; method: " + methodName + "; line: " + bpLine);
+
+ int n = ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value();
+ Location loc = (Location) ((Method) testedClass.methodsByName(methodName).get(0)).allLineLocations().get(n);
+
+ BreakpointRequest
+ bpr = eventRManager.createBreakpointRequest(loc);
+ bpr.putProperty("number", property);
+ if (thread != null)
+ bpr.addThreadFilter(thread);
+ bpr.setSuspendPolicy(suspendPolicy);
+
+ display(" a breakpoint has been set up");
+ return bpr;
+ } catch ( Exception e ) {
+ throw new Failure("** FAILURE to set up BreakpointRequest **");
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004/TestDescription.java
new file mode 100644
index 00000000000..bab4f929e32
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004/TestDescription.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the implementation of an object of the type
+ * BreakpointRequest.
+ * The test checks up that a result of the method
+ * com.sun.jdi.BreakpointRequest.addThreadFilter()
+ * complies with its spec:
+ * public void addThreadFilter(ThreadReference thread)
+ * Restricts the events generated by this request to those in the given thread.
+ * Parameters: thread - the thread to filter on.
+ * Throws: InvalidRequestStateException -
+ * if this request is currently enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those in the given thread.
+ * The cases to test include re-invocations of the method
+ * addThreadFilter() on the same BreakpointRequest object.
+ * There are two BreakpointRequests to check as follows:
+ * (1) For BreakpointRequest2, both invocations are with different
+ * ThreadReferences restricting one Breakpoint event to two threads.
+ * The test expects no Breakpoint event will be received.
+ * (2) For BreakpointRequest1, both invocations are with the same
+ * ThreadReference restricting one Breakpoint event to one thread.
+ * The test expects this Breakpoint event will be received.
+ * The test works as follows:
+ * The debugger program - nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter004;
+ * the debuggee program - nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter004a.
+ * Using nsk.jdi.share classes,
+ * the debugger gets the debuggee running on another JavaVM,
+ * creates the object debuggee.VM, and waits for VMStartEvent.
+ * Upon getting the debuggee VM started,
+ * the debugger calls corresponding debuggee.VM methods to get
+ * needed data and to perform checks.
+ * In case of error the test produces the return value 97 and
+ * a corresponding error message(s).
+ * Otherwise, the test is passed and produces
+ * the return value 95 and no message.
+ * COMMENTS:
+ * 4930911 TEST_BUG: filter_rt006 debuggee has a race
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter004
+ * nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter004a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter004
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004a.java
new file mode 100644
index 00000000000..eee1d5a5cf4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004a.java
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.BreakpointRequest.addThreadFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * This class is used as debuggee application for the threadfilter004 JDI test.
+ */
+
+public class threadfilter004a {
+
+ //----------------------------------------------------- templete section
+
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ static ArgumentHandler argHandler;
+ static Log log;
+
+ //-------------------------------------------------- log procedures
+
+ private static void log1(String message) {
+ log.display("**> debuggee: " + message);
+ }
+
+ private static void logErr(String message) {
+ log.complain("**> debuggee: " + message);
+ }
+
+ //====================================================== test program
+
+ static Threadthreadfilter004a thread1 = null;
+ static Threadthreadfilter004a thread2 = null;
+
+ static threadfilter004aTestClass objTC = new threadfilter004aTestClass();
+
+ //------------------------------------------------------ common section
+
+ static int exitCode = PASSED;
+
+ static int instruction = 1;
+ static int end = 0;
+ // static int quit = 0;
+ // static int continue = 2;
+ static int maxInstr = 1; // 2;
+
+ static int lineForComm = 2;
+
+ private static void methodForCommunication() {
+ int i1 = instruction;
+ int i2 = i1;
+ int i3 = i2;
+ }
+ //---------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+
+ argHandler = new ArgumentHandler(argv);
+ log = argHandler.createDebugeeLog();
+
+ log1("debuggee started!");
+
+ label0:
+ for (int i = 0; ; i++) {
+
+ if (instruction > maxInstr) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break ;
+ }
+
+ switch (i) {
+
+ //------------------------------------------------------ section tested
+
+ case 0:
+ thread1 = new Threadthreadfilter004a("thread1");
+ thread2 = new Threadthreadfilter004a("thread2");
+ break;
+
+ case 1:
+ threadStart(thread1);
+ threadStart(thread2);
+ synchronized(lockingObj[0]) {
+ log1("synchronized(lockingObj[0])");
+ }
+ synchronized(lockingObj[1]) {
+ log1("synchronized(lockingObj[1])");
+ }
+
+
+ //------------------------------------------------- standard end section
+
+ default:
+ instruction = end;
+ break;
+ }
+ log1("methodForCommunication();");
+ methodForCommunication();
+ if (instruction == end)
+ break;
+ }
+
+ log1("debuggee exits");
+ System.exit(exitCode + PASS_BASE);
+ }
+
+
+ static Object waitnotifyObj = new Object();
+
+ static int threadStart(Thread t) {
+ synchronized (waitnotifyObj) {
+ t.start();
+ try {
+ waitnotifyObj.wait();
+ } catch ( Exception e) {
+ exitCode = FAILED;
+ logErr(" Exception : " + e );
+ return FAILED;
+ }
+ }
+ return PASSED;
+ }
+
+
+ static Object lockingObj[] = new Object[2];
+ static volatile int number = 0;
+
+ static class Threadthreadfilter004a extends Thread {
+
+ String tName = null;
+ int tNumber;
+
+ public Threadthreadfilter004a(String threadName) {
+ super(threadName);
+ tName = threadName;
+ tNumber = number;
+ number++;
+ lockingObj[tNumber] = threadName;
+ }
+
+ public void run() {
+ log1(" 'run': enter :: threadName == " + tName);
+ if (lockingObj[tNumber] == null)
+ log1("lockingObj[tNumber] == null");
+ synchronized(lockingObj[tNumber]) {
+ synchronized (waitnotifyObj) {
+ waitnotifyObj.notify();
+ }
+ objTC.method();
+ }
+ log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+ }
+
+}
+
+class threadfilter004aTestClass {
+
+ static int breakpointLine = 3;
+ static String awFieldName = "var1";
+ static String mwFieldName = "var2";
+
+ static int var1 = 0;
+ static int var2 = 0;
+ static int var3 = 0;
+
+ static void method () {
+ var1 = 1;
+ var3 = var1;
+ var2 = var3;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java
new file mode 100644
index 00000000000..df1281910d3
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java
@@ -0,0 +1,519 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.BreakpointRequest.location;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type com.sun.jdi.BreakpointRequest.location() com.sun.jdi.ByteValue.equals() null.PerformComparing
+ * method.PerformComparing is static field of testedObj,execTest readsPerformComparing for each of them.equals002a is deugee's part of the test.ClassToCheck delivers values for first parameter of equals.com.sun.jdi.ByteValue.hashCode() com.sun.jdi.ByteValue.value() com.sun.jdi.CharValue.equals() null.PerformComparing
+ * method.PerformComparing is static field of testedObj,execTest readsPerformComparing for each of them.equals002a is deugee's part of the test.ClassToCheck delivers values for first parameter of equals.com.sun.jdi.CharValue.value() com.sun.jdi.ClassLoader.definedClasses() com.sun.jdi.ClassLoader.visibleClasses() reflectedType()
+ * of the JDI interface ClassObjectReference of com.sun.jdi package
+ */
+
+public class reflectype001 extends Log {
+ static java.io.PrintStream out_stream;
+ static boolean verbose_mode = false; // test argument -vbs or -verbose switches to true
+ // - for more easy failure evaluation
+
+ /** The main class names of the debugger & debugee applications. */
+ private final static String
+ package_prefix = "nsk.jdi.ClassObjectReference.reflectedType.",
+// package_prefix = "", // for DEBUG without package
+ thisClassName = package_prefix + "reflectype001",
+ debugeeName = thisClassName + "a";
+
+
+ static ArgumentHandler argsHandler;
+ private static Log logHandler;
+
+
+ /** Debugee's classes for check **/
+ private final static String classes_for_check[][] = {
+
+ {"boolean", "primitive_type", "class"},
+ {"byte" , "primitive_type", "class"},
+ {"char" , "primitive_type", "class"},
+ {"double" , "primitive_type", "class"},
+ {"float" , "primitive_type", "class"},
+ {"int" , "primitive_type", "class"},
+ {"long" , "primitive_type", "class"},
+
+ {"java.lang.Boolean" , "reference_type", "class"},
+ {"java.lang.Byte" , "reference_type", "class"},
+ {"java.lang.Character", "reference_type", "class"},
+ {"java.lang.Double" , "reference_type", "class"},
+ {"java.lang.Float" , "reference_type", "class"},
+ {"java.lang.Integer" , "reference_type", "class"},
+ {"java.lang.Long" , "reference_type", "class"},
+ {"java.lang.String" , "reference_type", "class"},
+ {"java.lang.Object" , "reference_type", "class"},
+
+ {debugeeName+"$s_class", "reference_type", "class"}, // static class
+ {debugeeName+"$s_interf", "reference_type", "interface"}, // static interface
+
+ {package_prefix + "package_class", "reference_type", "class"}, // class
+ {package_prefix + "package_interf", "reference_type", "interface"} // interface
+
+ };
+
+ /**
+ * Re-call to run(args,out), and exit with
+ * either status 95 or 97 (JCK-like exit status).
+ */
+ public static void main (String argv[]) {
+ int exitCode = run(argv,System.out);
+ System.exit(exitCode + 95/*STATUS_TEMP*/);
+ }
+
+ /**
+ * JCK-like entry point to the test: perform testing, and
+ * return exit code 0 (PASSED) or either 2 (FAILED).
+ */
+ public static int run (String argv[], PrintStream out) {
+ out_stream = out;
+
+ int v_test_result = new reflectype001().runThis(argv,out_stream);
+ if ( v_test_result == 2/*STATUS_FAILED*/ ) {
+ logHandler.complain("\n==> nsk/jdi/ClassObjectReference/reflectedType/reflectype001 test FAILED");
+ }
+ else {
+ logHandler.display("\n==> nsk/jdi/ClassObjectReference/reflectedType/reflectype001 test PASSED");
+ }
+ return v_test_result;
+ }
+
+ private void print_log_on_verbose(String message) {
+ logHandler.display(message);
+ }
+
+ /**
+ * Non-static variant of the method run(args,out)
+ */
+ private int runThis (String argv[], PrintStream out) {
+ if ( out_stream == null ) {
+ out_stream = out;
+ }
+
+
+ Debugee debugee;
+
+ argsHandler = new ArgumentHandler(argv);
+ logHandler = new Log(out, argsHandler);
+ Binder binder = new Binder(argsHandler, logHandler);
+
+
+ if (argsHandler.verbose()) {
+ debugee = binder.bindToDebugee(debugeeName + " -vbs");
+ } else {
+ debugee = binder.bindToDebugee(debugeeName);
+ }
+
+ IOPipe pipe = new IOPipe(debugee);
+
+ logHandler.display("==> nsk/jdi/ClassObjectReference/reflectedType/reflectype001 test LOG:");
+ logHandler.display("==> test checks reflectedType() method of ClassObjectReference interface ");
+ logHandler.display(" of the com.sun.jdi package for ArraType, ClassType, InterfaceType\n");
+
+
+ debugee.redirectStderr(out);
+ print_log_on_verbose("--> reflectype001: reflectype001a debugee launched");
+ debugee.resume();
+
+ String line = pipe.readln();
+ if (line == null) {
+ logHandler.complain
+ ("##> reflectype001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
+ return 2/*STATUS_FAILED*/;
+ }
+ if (!line.equals("ready")) {
+ logHandler.complain
+ ("##> reflectype001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
+ return 2/*STATUS_FAILED*/;
+ }
+ else {
+ print_log_on_verbose("--> reflectype001: debugee's \"ready\" signal recieved!");
+ }
+
+ logHandler.display
+ ("--> reflectype001: check ClassObjectReference.reflectedType() method for debugee's classes...");
+ int all_classes_count = 0;
+ int class_not_found_errors = 0;
+ int classObject_method_errors = 0;
+ for (int i=0; ireflectedType()
+ * of the JDI interface ClassObjectReference of com.sun.jdi package
+ */
+
+public class reflectype002 extends Log {
+ static java.io.PrintStream out_stream;
+ static boolean verbose_mode = false; // test argument -vbs or -verbose switches to true
+ // - for more easy failure evaluation
+
+ /** The main class names of the debugger & debugee applications. */
+ private final static String
+ package_prefix = "nsk.jdi.ClassObjectReference.reflectedType.",
+ thisClassName = package_prefix + "reflectype002",
+ debugeeName = thisClassName + "a";
+
+ /** Debugee's class for check **/
+ private final static String checked_class = package_prefix + "reflectype002b";
+
+
+ /**
+ * Re-call to run(args,out), and exit with
+ * either status 95 or 97 (JCK-like exit status).
+ */
+ public static void main (String argv[]) {
+ int exitCode = run(argv,System.out);
+ System.exit(exitCode + 95/*STATUS_TEMP*/);
+ }
+
+ /**
+ * JCK-like entry point to the test: perform testing, and
+ * return exit code 0 (PASSED) or either 2 (FAILED).
+ */
+ public static int run (String argv[], PrintStream out) {
+ out_stream = out;
+
+ int v_test_result = new reflectype002().runThis(argv,out_stream);
+ if ( v_test_result == 2/*STATUS_FAILED*/ ) {
+ out_stream.println
+ ("\n==> nsk/jdi/ClassObjectReference/reflectedType/reflectype002 test FAILED");
+ }
+ else {
+ out_stream.println
+ ("\n==> nsk/jdiClassObjectReference/reflectedType/reflectype002 test PASSED");
+ }
+ return v_test_result;
+ }
+
+ private void print_log_on_verbose(String message) {
+ display(message);
+ }
+
+ private static void print_log_without_verbose(String message) {
+ if ( ! verbose_mode ) {
+ out_stream.println(message);
+ }
+ }
+
+ /**
+ * Non-static variant of the method run(args,out)
+ */
+ private int runThis (String argv[], PrintStream out) {
+ if ( out_stream == null ) {
+ out_stream = out;
+ }
+
+ out_stream.println("==> nsk/jdi/ClassObjectReference/reflectedType/reflectype002 test LOG:");
+ out_stream.println("--> test checks reflectedType() method of ClassObjectReference interface ");
+ out_stream.println(" of the com.sun.jdi package for UNLOADED class\n");
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ verbose_mode = argHandler.verbose();
+ argv = argHandler.getArguments();
+
+ String debugee_launch_command = debugeeName;
+ if (verbose_mode) {
+ logTo(out_stream);
+ }
+
+ Binder binder = new Binder(argHandler,this);
+ Debugee debugee = binder.bindToDebugee(debugee_launch_command);
+ IOPipe pipe = debugee.createIOPipe();
+
+ debugee.redirectStderr(out);
+ print_log_on_verbose("--> reflectype002: reflectype002a debugee launched");
+ debugee.resume();
+
+ String debugee_signal = pipe.readln();
+ if (debugee_signal == null) {
+ out_stream.println
+ ("##> reflectype002: UNEXPECTED debugee's signal (not \"ready0\") - " + debugee_signal);
+ return 2/*STATUS_FAILED*/;
+ }
+ if (!debugee_signal.equals("ready0")) {
+ out_stream.println
+ ("##> reflectype002: UNEXPECTED debugee's signal (not \"ready0\") - " + debugee_signal);
+ return 2/*STATUS_FAILED*/;
+ }
+ else {
+ print_log_on_verbose("--> reflectype002: debugee's \"ready0\" signal recieved!");
+ }
+
+ debugee_signal = pipe.readln();
+ if (debugee_signal == null) {
+ out_stream.println
+ ("##> reflectype002: UNEXPECTED debugee's signal (not \"ready1\") - " + debugee_signal);
+ return 2/*STATUS_FAILED*/;
+ }
+ if (!debugee_signal.equals("ready1")) {
+ out_stream.println
+ ("##> reflectype002: UNEXPECTED debugee's signal (not \"ready1\") - " + debugee_signal);
+ return 2/*STATUS_FAILED*/;
+ }
+ else {
+ print_log_on_verbose("--> reflectype002: debugee's \"ready1\" signal recieved!");
+ }
+
+ boolean class_not_found_error = false;
+ boolean reflectedType_method_error = false;
+ while ( true ) {
+ print_log_on_verbose
+ ("--> reflectype002: getting ReferenceType object for loaded checked class...");
+ ReferenceType refType = debugee.classByName(checked_class);
+ if (refType == null) {
+ print_log_without_verbose
+ ("--> reflectype002: getting ReferenceType object for loaded checked class...");
+ out_stream.println("##> reflectype002: FAILED: Could NOT FIND checked class: " + checked_class);
+ class_not_found_error = true;
+ break;
+ }
+ else {
+ print_log_on_verbose("--> reflectype002: checked class FOUND: " + checked_class);
+ }
+
+ print_log_on_verbose
+ ("--> reflectype002: getting ClassObjectReference object for loaded checked class...");
+ ClassObjectReference class_obj_ref = refType.classObject();;
+ print_log_on_verbose("--> reflectype002: getting ClassObjectReference object - DONE!");
+
+ print_log_on_verbose
+ ("--> reflectype002: waiting for \"ready2\" or \"not_unloaded\" signal from debugee...");
+ pipe.println("continue");
+ debugee_signal = pipe.readln();
+ if (debugee_signal == null) {
+ out_stream.println
+ ("##> reflectype002: UNEXPECTED debugee's signal - " + debugee_signal);
+ return 2/*STATUS_FAILED*/;
+ }
+ if ( debugee_signal.equals("not_unloaded")) {
+ out_stream.println
+ ("--> reflectype002: debugee's \"not_unloaded\" signal recieved!");
+ print_log_without_verbose
+ ("--> checked class may be NOT unloaded!");
+ out_stream.println
+ ("--> ClassObjectReference.reflectedType() method can NOT be checked!");
+ break;
+ }
+ if (!debugee_signal.equals("ready2")) {
+ out_stream.println
+ ("##> reflectype002: UNEXPECTED debugee's signal (not \"ready2\") - " + debugee_signal);
+ return 2/*STATUS_FAILED*/;
+ }
+ else {
+ print_log_on_verbose("--> reflectype002: debugee's \"ready2\" signal recieved!");
+ }
+ print_log_on_verbose
+ ("--> reflectype002: check that checked class has been unloaded realy...");
+ ReferenceType refType2 = debugee.classByName(checked_class);
+ if (refType2 == null) {
+ print_log_on_verbose
+ ("--> reflectype002: checked class has been unloaded realy: " + checked_class);
+ }
+ else {
+ print_log_without_verbose
+ ("--> reflectype002: check that checked class has been unloaded realy...");
+ out_stream.println
+ ("--> reflectype002: checked class FOUND: " + checked_class
+ + " => it has NOT been unloaded!");
+ out_stream.println
+ ("--> ClassObjectReference.reflectedType() method can NOT be checked!");
+ break;
+ }
+
+ out_stream.println
+ ("--> reflectype002: check ClassObjectReference.reflectedType() method for unloaded class...");
+ try {
+ refType2 = class_obj_ref.reflectedType();
+ }
+ catch (Exception expt) {
+ if (expt instanceof com.sun.jdi.ObjectCollectedException) {
+ out_stream.println
+ ("--> reflectype002: PASSED: expected Exception thrown - " + expt.toString());
+ }
+ else {
+ out_stream.println
+ ("##> reflectype002: FAILED: unexpected Exception thrown - " + expt.toString());
+ out_stream.println
+ ("##> expected Exception - com.sun.jdi.ObjectCollectedException");
+ reflectedType_method_error = true;
+ }
+ }
+ break;
+ }
+ int v_test_result = 0/*STATUS_PASSED*/;
+ if ( class_not_found_error || reflectedType_method_error ) {
+ v_test_result = 2/*STATUS_FAILED*/;
+ }
+
+ print_log_on_verbose("--> reflectype002: waiting for debugee finish...");
+ pipe.println("quit");
+ debugee.waitFor();
+
+ int status = debugee.getStatus();
+ if (status != 0/*STATUS_PASSED*/ + 95/*STATUS_TEMP*/) {
+ out_stream.println
+ ("##> reflectype002: UNEXPECTED Debugee's exit status (not 95) - " + status);
+ v_test_result = 2/*STATUS_FAILED*/;
+ }
+ else {
+ print_log_on_verbose
+ ("--> reflectype002: expected Debugee's exit status - " + status);
+ }
+
+ return v_test_result;
+ }
+} // end of reflectype002 class
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002/TEST.properties b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002/TEST.properties
new file mode 100644
index 00000000000..8b51b2a9115
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002/TEST.properties
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2018, 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.
+#
+
+exclusiveAccess.dirs=.
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002/TestDescription.java
new file mode 100644
index 00000000000..ab1416ed8d7
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002/TestDescription.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassObjectReference/reflectedType/reflectype002.
+ * VM Testbase keywords: [jpda, jdi, nonconcurrent]
+ * VM Testbase readme:
+ * DESCRIPTION
+ * nsk/jdi/ClassObjectReference/reflectedType/reflectype002 test
+ * checks the reflectedType() method of ClassObjectReference interface
+ * of the com.sun.jdi package for UNLOADED class:
+ * the test loads a class, gets a ReferenceType instance for this
+ * class, then gets a ClassObjectReference instance, then enforces
+ * the class to be unloaded and calls the reflectedType() method -
+ * the com.sun.jdi.ObjectCollectedException should be thrown in this case.
+ * COMMENTS
+ * Fixed test due to bug
+ * 4463674: TEST_BUG: some JDI tests are timing dependent
+ * The test was modified to comply with new execution scheme to have separate
+* directory for precompiled classes:
+ * - reflectype002b class was moved in 'loadclass' subdirectory;
+ * - package name was added in reflectype002b class;
+ * - ${COMMON_CLASSES_LOCATION} instead of ${TESTDIR} in .cfg file;
+ * - ClassUnloader seekes for reflectype002b class in
+ * ${COMMON_CLASSES_LOCATION}/loadclass directory.
+ * 4505735 equals002 and other tests fail with merlin
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.ClassObjectReference.reflectedType.reflectype002
+ * nsk.jdi.ClassObjectReference.reflectedType.reflectype002a
+ *
+ * @comment compile loadclassXX to bin/loadclassXX
+ * @run driver nsk.share.ExtraClassesBuilder
+ * loadclass
+ *
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.ClassObjectReference.reflectedType.reflectype002
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}" ./bin
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002/loadclass/reflectype002b.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002/loadclass/reflectype002b.java
new file mode 100644
index 00000000000..4df4167218d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002/loadclass/reflectype002b.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2000, 2018, 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.
+ */
+
+// this class will be loaded and then onloaded to check
+// the reflectedType() method of ClassObjectReference interface for UNLOADED class
+
+package nsk.jdi.ClassObjectReference.reflectedType;
+
+class reflectype002b {}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002a.java
new file mode 100644
index 00000000000..0f5cda75751
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/reflectedType/reflectype002a.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2000, 2018, 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.
+ */
+
+package nsk.jdi.ClassObjectReference.reflectedType;
+
+import java.lang.reflect.*;
+import java.io.*;
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+
+/**
+ * This class is used as debugee application for the reflectype002 JDI test.
+ */
+
+public class reflectype002a {
+
+ static boolean verbose_mode = false; // debugger may switch to true
+ // - for more easy failure evaluation
+
+ private final static String package_prefix = "nsk.jdi.ClassObjectReference.reflectedType.";
+ private final static String checked_class_name = package_prefix + "reflectype002b";
+
+ private static void print_log_on_verbose(String message) {
+ if ( verbose_mode ) {
+ System.err.println(message);
+ }
+ }
+
+ public static void main (String argv[]) {
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ verbose_mode = argHandler.verbose();
+
+ print_log_on_verbose("**> reflectype002a: debugee started!");
+ IOPipe pipe = argHandler.createDebugeeIOPipe();
+ pipe.println("ready0");
+
+ String checked_class_dir = (argHandler.getArguments())[0] + File.separator + "loadclass";
+
+ print_log_on_verbose("**> reflectype002a: waiting for \"checked class dir\" info...");
+
+ ClassUnloader classUnloader = new ClassUnloader();
+
+ try {
+ classUnloader.loadClass(checked_class_name, checked_class_dir);
+ print_log_on_verbose
+ ("--> reflectype002a: checked class loaded:" + checked_class_name);
+ }
+ catch ( Exception e ) { // ClassNotFoundException
+ System.err.println
+ ("**> reflectype002a: load class: exception thrown = " + e.toString());
+ print_log_on_verbose
+ ("--> reflectype002a: checked class NOT loaded:" + checked_class_name);
+ // Debuuger finds this fact itself
+ }
+
+ print_log_on_verbose("**> reflectype002a: waiting for \"continue\" or \"quit\" signal...");
+ pipe.println("ready1");
+ String instruction = pipe.readln();
+ if (instruction.equals("quit")) {
+ print_log_on_verbose("**> reflectype002a: \"quit\" signal recieved!");
+ print_log_on_verbose("**> reflectype002a: completed!");
+ System.exit(0/*STATUS_PASSED*/ + 95/*STATUS_TEMP*/);
+ }
+ if ( ! instruction.equals("continue")) {
+ System.err.println
+ ("##> reflectype002a: unexpected signal (no \"continue\" or \"quit\") - " + instruction);
+ System.err.println("##> reflectype002a: FAILED!");
+ System.exit(2/*STATUS_FAILED*/ + 95/*STATUS_TEMP*/);
+ }
+
+ print_log_on_verbose("**> reflectype002a: \"continue\" signal recieved!");
+ print_log_on_verbose("**> reflectype002a: enforce to unload checked class...");
+
+ boolean test_class_loader_finalized = classUnloader.unloadClass();
+
+ if ( ! test_class_loader_finalized ) {
+ print_log_on_verbose("**> reflectype002a: checked class may be NOT unloaded!");
+ pipe.println("not_unloaded");
+ }
+ else {
+ print_log_on_verbose("**> reflectype002a: checked class unloaded!");
+ pipe.println("ready2");
+ }
+ print_log_on_verbose("**> reflectype002a: waiting for \"quit\" signal...");
+ instruction = pipe.readln();
+ if (instruction.equals("quit")) {
+ print_log_on_verbose("**> reflectype002a: \"quit\" signal recieved!");
+ print_log_on_verbose("**> reflectype002a: completed!");
+ System.exit(0/*STATUS_PASSED*/ + 95/*STATUS_TEMP*/);
+ }
+ System.err.println("##> reflectype002a: unexpected signal (no \"quit\") - " + instruction);
+ System.err.println("##> reflectype002a: FAILED!");
+ System.exit(2/*STATUS_FAILED*/ + 95/*STATUS_TEMP*/);
+ }
+} // end of reflectype002a class
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001.java
new file mode 100644
index 00000000000..0f66d1e01bd
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassObjectReference.toString;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.connect.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * The debugger application of the test.
+ */
+public class tostring001 {
+
+ //------------------------------------------------------- immutable common fields
+
+ final static String SIGNAL_READY = "ready";
+ final static String SIGNAL_GO = "go";
+ final static String SIGNAL_QUIT = "quit";
+
+ private static int waitTime;
+ private static int exitStatus;
+ private static ArgumentHandler argHandler;
+ private static Log log;
+ private static Debugee debuggee;
+ private static ReferenceType debuggeeClass;
+
+ //------------------------------------------------------- mutable common fields
+
+ private final static String prefix = "nsk.jdi.ClassObjectReference.toString.";
+ private final static String className = "tostring001";
+ private final static String debuggerName = prefix + className;
+ private final static String debuggeeName = debuggerName + "a";
+
+ //------------------------------------------------------- test specific fields
+
+ /** debuggee's methods for check **/
+ private final static String checkedClasses[] = {
+ "java.lang.Boolean" ,
+ "java.lang.Byte" ,
+ "java.lang.Character",
+ "java.lang.Double" ,
+ "java.lang.Float" ,
+ "java.lang.Integer" ,
+ "java.lang.Long" ,
+ "java.lang.Short" ,
+ "java.lang.String" ,
+ "java.lang.Object" ,
+
+ debuggeeName + "$innerClass",
+ debuggeeName + "$innerInterf",
+ prefix + "tostring001aClass",
+ prefix + "tostring001aInterf"
+ };
+
+ //------------------------------------------------------- immutable common methods
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ private static void display(String msg) {
+ log.display("debugger > " + msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE > " + msg);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debuggee = Debugee.prepareDebugee(argHandler, log, debuggeeName);
+
+ debuggeeClass = debuggee.classByName(debuggeeName);
+ if ( debuggeeClass == null ) {
+ complain("Class '" + debuggeeName + "' not found.");
+ exitStatus = Consts.TEST_FAILED;
+ }
+
+ execTest();
+
+ debuggee.quit();
+
+ return exitStatus;
+ }
+
+ //------------------------------------------------------ mutable common method
+
+ private static void execTest() {
+
+ BreakpointRequest brkp = debuggee.setBreakpoint(debuggeeClass,
+ tostring001a.brkpMethodName,
+ tostring001a.brkpLineNumber);
+ debuggee.resume();
+
+ debuggee.sendSignal(SIGNAL_GO);
+ Event event = null;
+
+ // waiting the breakpoint event
+ try {
+ event = debuggee.waitingEvent(brkp, waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("unexpected InterruptedException while waiting for Breakpoint event");
+ }
+ if (!(event instanceof BreakpointEvent)) {
+ debuggee.resume();
+ throw new Failure("BreakpointEvent didn't arrive");
+ }
+
+ ThreadReference thread = ((BreakpointEvent)event).thread();
+ List params = new Vector();
+ ClassType testedClass = (ClassType)debuggeeClass;
+
+ display("Checking toString() method for ClassObjectReferences of debuggee's fields...");
+ String brackets[] = {"", "[]", "[][]"};
+
+ for (int i=0; i < checkedClasses.length; i++) {
+
+ String basicName = checkedClasses[i];
+
+ for (int dim = 0; dim<3; dim++) {
+
+ String className = basicName + brackets[dim];
+ ReferenceType refType = debuggee.classByName(className);
+ if (refType == null) {
+ complain("Could NOT FIND class: " + className);
+ exitStatus = Consts.TEST_FAILED;
+ continue;
+ }
+
+ try {
+ ClassObjectReference classObjRef = refType.classObject();
+ String str = classObjRef.toString();
+ if (str == null) {
+ complain("toString() returns null for ClassObjectReferences of debugges's field: " + className);
+ exitStatus = Consts.TEST_FAILED;
+ } else if (str.length() == 0) {
+ complain("toString() returns empty string for ClassObjectReferences of debugges's field: " + className);
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("toString() method returns for " + className + " : " + str);
+ }
+ } catch(Exception e) {
+ complain("unexpected " + e + " while taking ClassObjectReferences of debugges's field: " + className);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ }
+ }
+
+ display("Checking completed!");
+ debuggee.resume();
+ }
+
+ //--------------------------------------------------------- test specific methods
+
+}
+//--------------------------------------------------------- test specific classes
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001/TestDescription.java
new file mode 100644
index 00000000000..f2ad8f6687c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001/TestDescription.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassObjectReference/toString/tostring001.
+ * VM Testbase keywords: [quick, jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for public toString() method of an implementing class of
+ * com.sun.jdi.ClassObjectReference interface.
+ * The test checks an assertion:
+ * In conformity with the contract for java.lang.Object.toString(),
+ * the overrided method returns representing non-empty string for
+ * for a ClassObjectReference object of a debuggee class's field.
+ * COMMENTS:
+ * The test is aimed to increase jdi source code coverage and checks
+ * the code which was not yet covered by previous tests for ClassObjectReference
+ * interface. The coverage analysis was done for jdk1.4.0-b92 build.
+ * Test was fixed according to test bug:
+ * 4778296 TEST_BUG: debuggee VM intemittently hangs after resuming
+ * - handling VMStartEvent was removed from the debugger part of the test
+ * Test fixed according to test bug:
+ * 4798088 TEST_BUG: setBreakpoint() method depends of the locations implementation
+ * - using standard Debugee.setBreakpoint() method
+ * - adjusting source line numbers used for setting breakpoint
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.ClassObjectReference.toString.tostring001
+ * nsk.jdi.ClassObjectReference.toString.tostring001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.ClassObjectReference.toString.tostring001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001a.java
new file mode 100644
index 00000000000..7764bff0268
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001a.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassObjectReference.toString;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * The debugged applcation of the test.
+ */
+public class tostring001a {
+
+ //------------------------------------------------------- immutable common fields
+
+ private static int exitStatus;
+ private static ArgumentHandler argHandler;
+ private static Log log;
+ private static IOPipe pipe;
+
+ //------------------------------------------------------- immutable common methods
+
+ static void display(String msg) {
+ log.display("debuggee > " + msg);
+ }
+
+ static void complain(String msg) {
+ log.complain("debuggee FAILURE > " + msg);
+ }
+
+ public static void receiveSignal(String signal) {
+ String line = pipe.readln();
+
+ if ( !line.equals(signal) )
+ throw new Failure("UNEXPECTED debugger's signal " + line);
+
+ display("debuger's <" + signal + "> signal received.");
+ }
+
+ //------------------------------------------------------ mutable common fields
+
+ //------------------------------------------------------ test specific fields
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 121;
+
+ // Classes must be loaded and linked, so all fields must be
+ // initialized
+ Boolean Z0 = new Boolean(true), Z1[]={Z0}, Z2[][]={Z1};
+ Byte B0 = new Byte((byte)1), B1[]={B0}, B2[][]={B1};
+ Character C0 = new Character('\u00ff'), C1[]={C0}, C2[][]={C1};
+ Double D0 = new Double(1.0), D1[]={D0}, D2[][]={D1};
+ Float F0 = new Float(1.0f), F1[]={F0}, F2[][]={F1};
+ Integer I0 = new Integer(-1), I1[]={I0}, I2[][]={I1};
+ Long L0 = new Long(-1l), L1[]={L0}, L2[][]={L1};
+ Short H0 = new Short((short)-1), H1[]={H0}, H2[][]={H1};
+ String S0 = new String("4434819"), S1[]={S0}, S2[][]={S1};
+ Object O0 = new Object(), O1[]={O0}, O2[][]={O1};
+
+ // Interfaces must be loaded and linked, so classes that implement
+ // interfaces must be initialized.
+ static class innerClass {}
+ static interface innerInterf {}
+ protected static class innerInterfImpl implements innerInterf {}
+ innerInterfImpl sii0 = new innerInterfImpl();
+
+ innerClass innerClass0 = new innerClass();
+ innerClass innerClass1[] = {innerClass0};
+ innerClass innerClass2[][] = {innerClass1};
+
+ innerInterf innerInterf0;
+ innerInterf innerInterf1[] = {innerInterf0};
+ innerInterf innerInterf2[][] = {innerInterf1};
+
+ tostring001aClass tostring001aClass0 = new tostring001aClass();
+ tostring001aClass tostring001aClass1[] = {tostring001aClass0};
+ tostring001aClass tostring001aClass2[][] = {tostring001aClass1};
+
+ class tostring001aInterfImpl implements tostring001aInterf {}
+ tostring001aInterfImpl pii0 = new tostring001aInterfImpl();
+ tostring001aInterf tostring001aInterf0;
+ tostring001aInterf tostring001aInterf1[] = {tostring001aInterf0};
+ tostring001aInterf tostring001aInterf2[][] = {tostring001aInterf1};
+
+ //------------------------------------------------------ mutable common method
+
+ public static void main (String argv[]) {
+ exitStatus = Consts.TEST_FAILED;
+ argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ pipe = argHandler.createDebugeeIOPipe(log);
+
+ tostring001a dummy = new tostring001a();
+
+ try {
+ pipe.println(tostring001.SIGNAL_READY);
+ receiveSignal(tostring001.SIGNAL_GO);
+ log.display("breakpoint line"); // brkpLineNumber
+ receiveSignal(tostring001.SIGNAL_QUIT);
+ display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ } catch (Failure e) {
+ log.complain(e.getMessage());
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+ }
+
+ //--------------------------------------------------------- test specific methods
+}
+
+//--------------------------------------------------------- test specific classes
+class tostring001aClass {}
+interface tostring001aInterf {}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareEvent/referenceType/refType001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareEvent/referenceType/refType001.java
new file mode 100644
index 00000000000..e576e58be4c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareEvent/referenceType/refType001.java
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareEvent.referenceType;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.io.*;
+import java.util.Iterator;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+
+// This class is the debugger in the test
+
+public class refType001 {
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int JCK_STATUS_BASE = 95;
+
+ static final int TIMEOUT_DELTA = 1000; // milliseconds
+
+ static final String COMMAND_READY = "ready";
+ static final String COMMAND_QUIT = "quit";
+ static final String COMMAND_RUN = "run";
+ static final String COMMAND_DONE = "done";
+ static final String COMMAND_ERROR = "error";
+
+ static final String PACKAGE_NAME = "nsk.jdi.ClassPrepareEvent.referenceType";
+ static final String DEBUGEE_NAME = PACKAGE_NAME + ".refType001a";
+
+ static private Debugee debuggee;
+ static private VirtualMachine vm;
+ static private IOPipe pipe;
+ static private Log log;
+ static private ArgumentHandler argHandler;
+
+ static private ClassPrepareRequest checkedRequest;
+ static private ThreadReference debuggeeThread;
+ static private volatile String checkedTypes[][] = {
+ {"main", "refType001a", "0"},
+ {"main", "AnotherThread", "0"},
+ {"AnotherThread", "ClassForAnotherThread", "0"},
+ {"AnotherThread", "Inter", "0"}
+ };
+
+ static private volatile boolean testFailed, eventsReceived, threadsStarted;
+ static private int eventTimeout;
+
+ public static void main (String args[]) {
+ System.exit(run(args, System.out) + JCK_STATUS_BASE);
+ }
+
+ public static int run(final String args[], final PrintStream out) {
+ String command;
+
+ testFailed = false;
+ eventsReceived = false;
+ threadsStarted = false;
+
+
+ argHandler = new ArgumentHandler(args);
+ log = new Log(out, argHandler);
+ eventTimeout = argHandler.getWaitTime() * 60 * 1000; // milliseconds
+
+ // launch debugee
+ Binder binder = new Binder(argHandler, log);
+ log.display("Connecting to debuggee");
+ debuggee = binder.bindToDebugee(DEBUGEE_NAME);
+ debuggee.redirectStderr(log, "refType001a >");
+ pipe = debuggee.createIOPipe();
+ vm = debuggee.VM();
+
+ // create request and wait for expected events
+ try {
+
+ // create request for ClassPrepareEvent
+ log.display("Creating request for ClassPrepareEvent");
+ EventRequestManager erManager = debuggee.VM().eventRequestManager();
+ if ((checkedRequest = erManager.createClassPrepareRequest()) == null) {
+ throw new Failure("TEST FAILED: unable to create ClassPrepareRequest");
+ }
+ log.display("ClassPrepareRequest is created");
+
+ // define separate thread to handle received events
+ class EventHandler extends Thread {
+
+ public void run() {
+
+ // handle events until all threads started and all expected events received
+ while (!(threadsStarted && eventsReceived)) {
+ EventSet eventSet = null;
+ try {
+ eventSet = vm.eventQueue().remove(TIMEOUT_DELTA);
+ } catch (InterruptedException e) {
+ throw new Failure("Unexpected InterruptedException while receiving events: " + e);
+ }
+
+ if (eventSet == null) {
+ continue;
+ }
+
+ // handle each event
+ EventIterator eventIterator = eventSet.eventIterator();
+ while (eventIterator.hasNext()) {
+ Event event = eventIterator.nextEvent();
+// log.display("\nEvent received:\n " + event);
+
+ // handle ClassPrepareEvent
+ if (event instanceof ClassPrepareEvent) {
+ ClassPrepareEvent castedEvent = (ClassPrepareEvent)event;
+ log.display("\nClassPrepareEvent received:\n " + event);
+
+ EventRequest eventRequest = castedEvent.request();
+ if (!(checkedRequest.equals(eventRequest))) {
+ log.complain("FAILURE 1: eventRequest is not equal to checked request");
+ testFailed = true;
+ }
+ VirtualMachine eventMachine = castedEvent.virtualMachine();
+ if (!(vm.equals(eventMachine))) {
+ log.complain("FAILURE 2: eventVirtualMachine is not equal to checked vm");
+ testFailed = true;
+ }
+
+ debuggeeThread = castedEvent.thread();
+ String threadName = debuggeeThread.name();
+
+ // test ClassPrepareEvent.referenceType() method
+ ReferenceType refType = castedEvent.referenceType();
+ if (refType == null) {
+ log.complain("FAILURE 3: ClassPrepareEvent.referenceType() returns null");
+ testFailed = true;
+ } else {
+
+ String refName = refType.name();
+ if ((refName == null) || (refName.equals(""))) {
+ log.complain("FAILURE 4: Reference has invalid empty name");
+ testFailed = true;
+ } else {
+ if ( refName.startsWith(PACKAGE_NAME)) {
+ log.display("Reference " + refName + " prepared in thread " + threadName);
+
+ // Check that all expected debuggee's thread create ClassPrepareEvent only once
+ for (int i = 0; i < checkedTypes.length; i++) {
+ if (threadName.equals(checkedTypes[i][0]) && refName.endsWith(checkedTypes[i][1])) {
+ if (checkedTypes[i][2] == "0") {
+ checkedTypes[i][2] = "1";
+ } else {
+ log.complain("FAILURE 5: ClassPrepareEvent for " + threadName + " is received more that once");
+ testFailed = true;
+ }
+ }
+ }
+
+ // Check that all static fields in reference type are initialized
+ Iterator fieldsList;
+ try {
+ fieldsList = refType.fields().iterator();
+ } catch (ClassNotPreparedException e) {
+ log.complain( "FAILURE 6: " + refName + " is not prepared");
+ testFailed = true;
+ throw new Failure("ClassNotPrepared exception caught: " + e);
+ }
+ while (fieldsList.hasNext()) {
+ Field refField = (Field)fieldsList.next();
+ if (refField.isStatic()) {
+ if (refField.equals(null)) {
+ log.complain( "FAILURE 7: " + refField.name() + " of " + refName + " is not initialized");
+ testFailed = true;
+ }
+ }
+ }
+
+ // Check that all expected ClassPrepareEvent are received
+ eventsReceived = true;
+ for (int i = 0; i < checkedTypes.length; i++) {
+ if (checkedTypes[i][2] == "0")
+ eventsReceived = false;
+ }
+ }
+ }
+
+ if (!refType.isPrepared()) {
+ log.complain("FAILURE 8: Reference " + refName + " is not prepared" );
+ testFailed = true;
+ }
+ }
+ }
+
+ // ignore each oter event
+
+ } // event handled
+
+// log.display("Resuming event set");
+ eventSet.resume();
+
+ } // event set handled
+
+ log.display("eventHandler completed");
+
+ } // for run()
+
+ } // for EventHandler
+
+ // start EventHandler thread
+ EventHandler eventHandler = new EventHandler();
+ log.display("Starting eventHandler");
+ eventHandler.start();
+
+ // enable event request and resume debugee
+ log.display("Enabling ClassPrepareEvent request");
+ checkedRequest.enable();
+
+ log.display("Resuming debuggee");
+ debuggee.resume();
+
+ // wait for debugee started
+ log.display("Waiting for command: " + COMMAND_READY);
+ command = pipe.readln();
+ if (!command.equals(COMMAND_READY)) {
+ throw new Failure("TEST BUG: unexpected debuggee's command: " + command);
+ }
+
+ // force debugee to start another thread
+ log.display("Sending a command: " + COMMAND_RUN);
+ pipe.println(COMMAND_RUN);
+
+ // wait for debugee started requested thread
+ log.display("Waiting for command: " + COMMAND_DONE);
+ command = pipe.readln();
+ if (!command.equals(COMMAND_DONE)) {
+ log.complain("TEST BUG: unexpected debuggee's command: " + command);
+ testFailed = true;
+ }
+
+ // notify EventHandler that all threads started
+ threadsStarted = true;
+
+ // wait for all expected events received or timeout exceeds
+ try {
+ eventHandler.join(eventTimeout);
+ if (eventHandler.isAlive()) {
+ log.complain("FAILURE 20: Timeout for waiting event was exceeded");
+ eventHandler.interrupt();
+ testFailed = true;
+ }
+ } catch (InterruptedException e) {
+ log.complain("TEST INCOMPLETE: InterruptedException caught while waiting for eventHandler's death");
+ testFailed = true;
+ }
+
+ // check that all expected debuggee's threads created ClassPrepareEvent
+ for (int i = 0; i < checkedTypes.length; i++) {
+ if (checkedTypes[i][2].equals("0")) {
+ log.complain("FAILURE 9: ClassPrepareEvent for " + checkedTypes[i][1] +
+ " in thread " + checkedTypes[i][0] + " is not received");
+ testFailed = true;
+ }
+ }
+
+ } catch (Failure e) {
+ log.complain("TEST FAILURE: " + e.getMessage());
+ testFailed = true;
+ } catch (Exception e) {
+ log.complain("Unexpected exception: " + e);
+ e.printStackTrace(out);
+ testFailed = true;
+ } finally {
+
+ // disable event requests to prevent appearance of further events
+ if (checkedRequest != null && checkedRequest.isEnabled()) {
+ log.display("Disabling StepEvent request");
+ checkedRequest.disable();
+ }
+
+ // force debugee to exit
+ log.display("Sending command: " + COMMAND_QUIT);
+ pipe.println(COMMAND_QUIT);
+
+ // wait for debuggee exits and analize its exit code
+ log.display("Waiting for debuggee terminating");
+ int debuggeeStatus = debuggee.endDebugee();
+ if (debuggeeStatus == PASSED + JCK_STATUS_BASE) {
+ log.display("Debuggee PASSED with exit code: " + debuggeeStatus);
+ } else {
+ log.complain("Debuggee FAILED with exit code: " + debuggeeStatus);
+ testFailed = true;
+ }
+ }
+
+ // check test results
+ if (testFailed) {
+ log.complain("TEST FAILED");
+ return FAILED;
+ }
+
+ log.display("TEST PASSED");
+ return PASSED;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareEvent/referenceType/refType001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareEvent/referenceType/refType001/TestDescription.java
new file mode 100644
index 00000000000..11ea84cec54
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareEvent/referenceType/refType001/TestDescription.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2018, 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
+ * @modules java.base/jdk.internal.misc:+open
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassPrepareEvent/referenceType/refType001.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION
+ * The test exercises
+ * com.sun.jdi.event.lassPrepareEvent.referenceType() method.
+ * The test checks the following assertions:
+ * - ClassPrepareEvent is always received by debugger
+ * for all prepared classes and interfaces in target VM,
+ * - ClassPrepareEvent is received only once for each checked
+ * class or interface
+ * - method ClassPrepareEvent.referenceType returns valid
+ * Reference Type in target VM,
+ * - all static fields and constants are initialized for checked
+ * prepared class or interface.
+ * A debugger class - nsk.jdi.ClassPrepareEvent.referenceType.refType001 ;
+ * a debuggee class - nsk.jdi.ClassPrepareEvent.referenceType.refType001a .
+ * The test uses supporting nsk/share/jdi classes for launching debuggee
+ * and for creating communication pipe between debugger and debuggee. The
+ * debugger and debugee communicates with special commands.
+ * The debugger creates ClassPrepareRequest and starts special thread
+ * addClassFilter(ReferenceType), addClassFilter(String), addClassExclusionFilter(String) null argument value.
+ * In any cases NullPointerException is expected.
+ */
+public class filters001 {
+
+ final static String prefix = "nsk.jdi.ClassPrepareRequest._bounds_.";
+ private final static String className = "filters001";
+ private final static String debuggerName = prefix + className;
+ private final static String debugeeName = debuggerName + "a";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+
+ private static void display(String msg) {
+ log.display("debugger> " + msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ filters001 thisTest = new filters001();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ thisTest.execTest();
+ display("execTest finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() {
+
+ ReferenceType debugeeRef = debugee.classByName(debugeeName);
+
+ display("");
+ display(">>>creating ClassPrepareRequest");
+ ClassPrepareRequest request =
+ debugee.getEventRequestManager().createClassPrepareRequest();
+
+ display("");
+ addClassFilter(request, (ReferenceType )null);
+ display("");
+ addClassFilter(request, (String )null);
+ display("");
+ addClassExclusionFilter(request, (String )null);
+
+ display("");
+ debugee.quit();
+ }
+
+ private void addClassFilter(ClassPrepareRequest request, ReferenceType refType) {
+
+ display("addClassFilter :ReferenceType> null");
+ try {
+ request.addClassFilter(refType);
+ complain("*****NullPointerException is not thrown");
+ exitStatus = Consts.TEST_FAILED;
+ } catch (NullPointerException e) {
+ display("!!!Expected " + e);
+ } catch (Exception e) {
+ complain("*****Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ }
+
+ private void addClassFilter(ClassPrepareRequest request, String classPattern) {
+
+ display("addClassFilter :classPattern> null");
+ try {
+ request.addClassFilter(classPattern);
+ complain("*****NullPointerException is not thrown");
+ exitStatus = Consts.TEST_FAILED;
+ } catch (NullPointerException e) {
+ display("!!!Expected " + e);
+ } catch (Exception e) {
+ complain("*****Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ }
+
+ private void addClassExclusionFilter(ClassPrepareRequest request,
+ String classPattern) {
+ display("addExclusionClassFilter :classPattern> null");
+ try {
+ request.addClassExclusionFilter(classPattern);
+ complain("*****NullPointerException is not thrown");
+ exitStatus = Consts.TEST_FAILED;
+ } catch (NullPointerException e) {
+ display("!!!Expected " + e);
+ } catch (Exception e) {
+ complain("*****Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/_bounds_/filters001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/_bounds_/filters001/TestDescription.java
new file mode 100644
index 00000000000..f165155c808
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/_bounds_/filters001/TestDescription.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassPrepareRequest/_bounds_/filters001.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the boundary value of the parameters.
+ * The test checks up that the methods
+ * com.sun.jdi.request.ClassPrepareRequest.addClassFilter(ReferenceType)
+ * com.sun.jdi.request.ClassPrepareRequest.addClassFilter(String)
+ * com.sun.jdi.request.ClassPrepareRequest.addClassExclusionFilter(String)
+ * correctly work for the boundary value of parameter and throw described
+ * exceptions.
+ * The test check up these methods with filters001a is deugee's part of the test.
+ */
+public class filters001a {
+
+ public static void main (String argv[]) {
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ Log log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+
+ pipe.println("ready");
+
+ String instr = pipe.readln();
+
+ if (instr.equals("quit")) {
+ log.display("DEBUGEE> completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001.java
new file mode 100644
index 00000000000..d684989d4e6
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassExclusionFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type
+ * ClassPrepareRequest.
+ *
+ * The test checks that results of the method
+ * com.sun.jdi.ClassPrepareRequest.addClassExclusionFilter(String)
+ * complies with its spec.
+ *
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those
+ * whose location is in a class
+ * whose name matches a restricted regular expression.
+ * The case to check includes a pattern that begins with '*'.
+ *
+ * The test works as follows.
+ * - The debugger
+ * - sets up a ClassPrepareRequest,
+ * - using a string pattern, restricts it with addClassExclusionFilter,
+ * - resumes the debuggee, and waits for ClassPrepareEvents.
+ * - The debuggee creates and starts a thread1,
+ * whose 'run' method creates objects of ClassTypes needed
+ * to generate Events and to test the filters.
+ * - Upon getting the events, the debugger performs the checks required.
+ */
+
+public class filter001 extends TestDebuggerType1 {
+
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ debuggeeName = "nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter001a";
+ return new filter001().runThis(argv, out);
+ }
+
+ private String classExclFilter1 = "*TestClass11";
+ private String classExclName1 = "nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.Thread1filter001a.TestClass11";
+
+ protected void testRun() {
+
+ EventRequest eventRequest1 = null;
+ String property1 = "ClassPrepareRequest1";
+ ThreadReference thread1 = null;
+
+ Event newEvent = null;
+
+ for (int i = 0; ; i++) {
+
+ if (!shouldRunAfterBreakpoint()) {
+ vm.resume();
+ break;
+ }
+
+ display(":::::: case: # " + i);
+
+ switch (i) {
+
+ case 0:
+ eventRequest1 = setting23ClassPrepareRequest(classExclFilter1,
+ EventRequest.SUSPEND_NONE,
+ property1);
+ eventRequest1.enable();
+ eventHandler.addListener(
+ new EventHandler.EventListener() {
+ public boolean eventReceived(Event event) {
+ if (event instanceof ClassPrepareEvent) {
+ String str = ((ClassPrepareEvent)event).referenceType().name();
+ if (str.endsWith(classExclName1)) {
+ setFailedStatus("Received unexpected ClassPrepareEvent for excluded class:" + str);
+ } else {
+ display("Received expected ClassPrepareEvent for " + str);
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+ );
+
+ display("......waiting for ClassPrepareEvent");
+ vm.resume();
+ break;
+
+ default:
+ throw new Failure("** default case 1 **");
+ }
+ }
+ return;
+ }
+
+ private ClassPrepareRequest setting23ClassPrepareRequest ( String classExclFilter,
+ int suspendPolicy,
+ String property )
+ throws Failure {
+ try {
+ display("......setting up ClassPrepareRequest:");
+ display(" class exclude filter: " + classExclFilter + "; property: " + property);
+
+ ClassPrepareRequest
+ cpr = eventRManager.createClassPrepareRequest();
+ cpr.putProperty("number", property);
+ cpr.setSuspendPolicy(suspendPolicy);
+
+ cpr.addClassExclusionFilter(classExclFilter);
+
+ display(" ClassPrepareRequest has been set up");
+ return cpr;
+ } catch ( Exception e ) {
+ throw new Failure("** FAILURE to set up ClassPrepareRequest **");
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001/TestDescription.java
new file mode 100644
index 00000000000..9919c145b81
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001/TestDescription.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2018, 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
+ * @modules java.base/jdk.internal.misc:+open
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the implementation of an object of the type
+ * ClassPrepareRequest.
+ * The test checks up that a result of the method
+ * com.sun.jdi.ClassPrepareRequest.addClassExclusionFilter()
+ * complies with its spec:
+ * public void addClassExclusionFilter(String classPattern)
+ * Restricts the events generated by this request to those
+ * whose location is in a class
+ * whose name does not match a restricted regular expression.
+ * Regular expressions are limited to exact matches and patterns that
+ * begin with '*' or end with '*'; for example, "*.Foo" or "java.*".
+ * Parameters: classPattern - the pattern String to filter for.
+ * Throws: InvalidRequestStateException -
+ * if this request is currently enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those
+ * whose location is in a class
+ * whose name matches a restricted regular expression.
+ * The cases to test include a pattern that begins with '*'.
+ * The test works as follows:
+ * The debugger program - nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter001;
+ * the debuggee program - nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter001a.
+ * Using nsk.jdi.share classes,
+ * the debugger gets the debuggee running on another JavaVM,
+ * creates the object debuggee.VM, and waits for VMStartEvent.
+ * Upon getting the debuggee VM started,
+ * the debugger calls corresponding debuggee.VM methods to get
+ * needed data and to perform checks.
+ * In case of error the test produces the return value 97 and
+ * a corresponding error message(s).
+ * Otherwise, the test is passed and produces
+ * the return value 95 and no message.
+ * COMMENTS:
+ * 4930911 TEST_BUG: filter_rt006 debuggee has a race
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter001
+ * nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001a.java
new file mode 100644
index 00000000000..e504ba0131e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001a.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassExclusionFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * This class is used as debuggee application for the filter001 JDI test.
+ */
+
+public class filter001a {
+
+ //----------------------------------------------------- templete section
+
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ static ArgumentHandler argHandler;
+ static Log log;
+
+ //-------------------------------------------------- log procedures
+
+ public static void log1(String message) {
+ log.display("**> debuggee: " + message);
+ }
+
+ private static void logErr(String message) {
+ log.complain("**> debuggee: " + message);
+ }
+
+ //====================================================== test program
+
+ static Thread1filter001a thread1 = null;
+
+ //------------------------------------------------------ common section
+
+ static int exitCode = PASSED;
+
+ static int instruction = 1;
+ static int end = 0;
+ // static int quit = 0;
+ // static int continue = 2;
+ static int maxInstr = 1; // 2;
+
+ static int lineForComm = 2;
+
+ private static void methodForCommunication() {
+ int i1 = instruction;
+ int i2 = i1;
+ int i3 = i2;
+ }
+ //---------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+
+ argHandler = new ArgumentHandler(argv);
+ log = argHandler.createDebugeeLog();
+
+ log1("debuggee started!");
+
+ label0:
+ for (int i = 0; ; i++) {
+
+ log1("methodForCommunication();");
+ methodForCommunication();
+ if (instruction == end)
+ break;
+
+ if (instruction > maxInstr) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break ;
+ }
+
+ switch (i) {
+
+//------------------------------------------------------ section tested
+
+ case 0:
+ thread1 = new Thread1filter001a("thread1");
+ log1("run1(thread1);");
+ run1(thread1);
+
+//------------------------------------------------- standard end section
+
+ default:
+ instruction = end;
+ break;
+ }
+ }
+
+ log1("debuggee exits");
+ System.exit(exitCode + PASS_BASE);
+ }
+
+ static Object waitnotifyObj = new Object();
+
+ static int threadStart(Thread t) {
+ synchronized (waitnotifyObj) {
+ t.start();
+ try {
+ waitnotifyObj.wait();
+ } catch ( Exception e) {
+ exitCode = FAILED;
+ logErr(" Exception : " + e );
+ return FAILED;
+ }
+ }
+ return PASSED;
+ }
+
+ static void run1(Thread t) {
+ t.start();
+ try {
+ t.join();
+ } catch ( InterruptedException e ) {
+ }
+ }
+
+}
+
+class Thread1filter001a extends Thread {
+
+ class TestClass10{
+ int var10 = 0;
+ }
+ class TestClass11 extends TestClass10{
+ int var11 = 0;
+ }
+
+ String tName = null;
+
+ public Thread1filter001a(String threadName) {
+ super(threadName);
+ tName = threadName;
+ }
+
+ public void run() {
+ filter001a.log1(" 'run': enter :: threadName == " + tName);
+ TestClass11 obj1 = new TestClass11();
+ filter001a.log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002.java
new file mode 100644
index 00000000000..7c0bdb383cf
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassExclusionFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type
+ * ClassPrepareRequest.
+ *
+ * The test checks that results of the method
+ * com.sun.jdi.ClassPrepareRequest.addClassExclusionFilter(String)
+ * complies with its spec.
+ *
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those
+ * whose location is in a class
+ * whose name matches a restricted regular expression.
+ * The case to check includes a pattern that ends with '*'.
+ *
+ * The test works as follows.
+ * - The debugger
+ * - sets up a ClassPrepareRequest,
+ * - using a string pattern, restricts it with addClassExclusionFilter,
+ * - resumes the debuggee, and waits for ClassPrepareEvents.
+ * - The debuggee creates and starts a thread1
+ * whose 'run' method creates objects of ClassTypes needed
+ * to generate Events and to test the filters.
+ * - Upon getting the events, the debugger performs the checks required.
+ */
+
+public class filter002 extends TestDebuggerType1 {
+
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ debuggeeName = "nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter002a";
+ return new filter002().runThis(argv, out);
+ }
+
+ private String classExclFilter1 = "nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.Thread1filter002a.TestClass11*";
+ private String classExclName1 = "nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.Thread1filter002a.TestClass11";
+
+ protected void testRun() {
+
+ EventRequest eventRequest1 = null;
+ String property1 = "ClassPrepareRequest1";
+ ThreadReference thread1 = null;
+
+ Event newEvent = null;
+
+ for (int i = 0; ; i++) {
+
+ if (!shouldRunAfterBreakpoint()) {
+ vm.resume();
+ break;
+ }
+
+ display(":::::: case: # " + i);
+
+ switch (i) {
+
+ case 0:
+ eventRequest1 = setting23ClassPrepareRequest(classExclFilter1,
+ EventRequest.SUSPEND_NONE,
+ property1);
+ eventRequest1.enable();
+ eventHandler.addListener(
+ new EventHandler.EventListener() {
+ public boolean eventReceived(Event event) {
+ if (event instanceof ClassPrepareEvent) {
+ String str = ((ClassPrepareEvent)event).referenceType().name();
+ if (str.endsWith(classExclName1)) {
+ setFailedStatus("Received ClassPrepareEvent for excluded class:" + str);
+ } else {
+ display("Received expected ClassPrepareEvent for " + str);
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+ );
+
+ display("......waiting for ClassPrepareEvent");
+ vm.resume();
+ break;
+
+ default:
+ throw new Failure("** default case 1 **");
+ }
+ }
+ return;
+ }
+
+ private ClassPrepareRequest setting23ClassPrepareRequest ( String classExclFilter,
+ int suspendPolicy,
+ String property )
+ throws Failure {
+ try {
+ display("......setting up ClassPrepareRequest:");
+ display(" class exclude filter: " + classExclFilter + "; property: " + property);
+
+ ClassPrepareRequest
+ cpr = eventRManager.createClassPrepareRequest();
+ cpr.putProperty("number", property);
+ cpr.setSuspendPolicy(suspendPolicy);
+
+ cpr.addClassExclusionFilter(classExclFilter);
+
+ display(" ClassPrepareRequest has been set up");
+ return cpr;
+ } catch ( Exception e ) {
+ throw new Failure("** FAILURE to set up ClassPrepareRequest **");
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002/TestDescription.java
new file mode 100644
index 00000000000..332ac00462f
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002/TestDescription.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2018, 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
+ * @modules java.base/jdk.internal.misc:+open
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the implementation of an object of the type
+ * ClassPrepareRequest.
+ * The test checks up that a result of the method
+ * com.sun.jdi.ClassPrepareRequest.addClassExclusionFilter()
+ * complies with its spec:
+ * public void addClassExclusionFilter(String classPattern)
+ * Restricts the events generated by this request to those
+ * whose location is in a class
+ * whose name does not match a restricted regular expression.
+ * Regular expressions are limited to exact matches and patterns that
+ * begin with '*' or end with '*'; for example, "*.Foo" or "java.*".
+ * Parameters: classPattern - the pattern String to filter for.
+ * Throws: InvalidRequestStateException -
+ * if this request is currently enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those
+ * whose location is in a class
+ * whose name matches a restricted regular expression.
+ * The cases to test include a pattern that ends with '*'.
+ * The test works as follows:
+ * The debugger program - nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter002;
+ * the debuggee program - nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter002a.
+ * Using nsk.jdi.share classes,
+ * the debugger gets the debuggee running on another JavaVM,
+ * creates the object debuggee.VM, and waits for VMStartEvent.
+ * Upon getting the debuggee VM started,
+ * the debugger calls corresponding debuggee.VM methods to get
+ * needed data and to perform checks.
+ * In case of error the test produces the return value 97 and
+ * a corresponding error message(s).
+ * Otherwise, the test is passed and produces
+ * the return value 95 and no message.
+ * COMMENTS:
+ * 4930911 TEST_BUG: filter_rt006 debuggee has a race
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter002
+ * nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter002a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.filter002
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002a.java
new file mode 100644
index 00000000000..b09f2db5490
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002a.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassExclusionFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * This class is used as debuggee application for the filter002 JDI test.
+ */
+
+public class filter002a {
+
+ //----------------------------------------------------- templete section
+
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ static ArgumentHandler argHandler;
+ static Log log;
+
+ //-------------------------------------------------- log procedures
+
+ public static void log1(String message) {
+ log.display("**> debuggee: " + message);
+ }
+
+ private static void logErr(String message) {
+ log.complain("**> debuggee: " + message);
+ }
+
+ //====================================================== test program
+
+ static Thread1filter002a thread1 = null;
+
+ //------------------------------------------------------ common section
+
+ static int exitCode = PASSED;
+
+ static int instruction = 1;
+ static int end = 0;
+ // static int quit = 0;
+ // static int continue = 2;
+ static int maxInstr = 1; // 2;
+
+ static int lineForComm = 2;
+
+ private static void methodForCommunication() {
+ int i1 = instruction;
+ int i2 = i1;
+ int i3 = i2;
+ }
+ //---------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+
+ argHandler = new ArgumentHandler(argv);
+ log = argHandler.createDebugeeLog();
+
+ log1("debuggee started!");
+
+ label0:
+ for (int i = 0; ; i++) {
+
+ log1("methodForCommunication();");
+ methodForCommunication();
+ if (instruction == end)
+ break;
+
+ if (instruction > maxInstr) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break ;
+ }
+
+ switch (i) {
+
+//------------------------------------------------------ section tested
+
+ case 0:
+ thread1 = new Thread1filter002a("thread1");
+ log1("run1(thread1);");
+ run1(thread1);
+
+//------------------------------------------------- standard end section
+
+ default:
+ instruction = end;
+ break;
+ }
+ }
+
+ log1("debuggee exits");
+ System.exit(exitCode + PASS_BASE);
+ }
+
+ static Object waitnotifyObj = new Object();
+
+ static int threadStart(Thread t) {
+ synchronized (waitnotifyObj) {
+ t.start();
+ try {
+ waitnotifyObj.wait();
+ } catch ( Exception e) {
+ exitCode = FAILED;
+ logErr(" Exception : " + e );
+ return FAILED;
+ }
+ }
+ return PASSED;
+ }
+
+ static void run1(Thread t) {
+ t.start();
+ try {
+ t.join();
+ } catch ( InterruptedException e ) {
+ }
+ }
+
+}
+
+class Thread1filter002a extends Thread {
+
+ class TestClass10{
+ int var10 = 0;
+ }
+ class TestClass11 extends TestClass10{
+ int var11 = 0;
+ }
+
+ String tName = null;
+
+ public Thread1filter002a(String threadName) {
+ super(threadName);
+ tName = threadName;
+ }
+
+ public void run() {
+ filter002a.log1(" 'run': enter :: threadName == " + tName);
+ TestClass11 obj1 = new TestClass11();
+ filter002a.log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java
new file mode 100644
index 00000000000..e852f747349
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java
@@ -0,0 +1,532 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassExclusionFilter;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type com.sun.jdi.ClassPrepareRequest.addClassExclusionFilter() com.sun.jdi.ClassPrepareRequest.addClassFilter_rt()
+ * complies with its spec.
+ *
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to be
+ * the preparation of the given reference type and any subtypes.
+ * An event will be generated for any prepared reference type
+ * that can be safely cast to the given reference type.
+ *
+ * The test works as follows.
+ * - The debugger resumes the debuggee and waits for the BreakpointEvent.
+ * - The debuggee creates a class filter object, to load the Class to
+ * filter, and invokes the methodForCommunication to be suspended and
+ * to inform the debugger with the event.
+ * - Upon getting the BreakpointEvent, the debugger
+ * - gets ReferenceType for the Class to filter,
+ * - sets up a ClassPrepareRequest and, using the ReferenceType,
+ * restricts it to sub-classes of the Class to filter,
+ * thus restricting the ClassPrepare event only to the thread1,
+ * - resumes debuggee's main thread, and
+ * - waits for the event.
+ * - The debuggee creates and starts two threads, thread1 and thread2,
+ * first of them will create an object of sub-Class to be filtered,
+ * whereas second will create an object to be not filtered.
+ * - Upon getting the event, the debugger performs the checks required.
+ */
+
+public class filter_rt001 extends TestDebuggerType1 {
+
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ debuggeeName = "nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt001a";
+ return new filter_rt001().runThis(argv, out);
+ }
+
+ private String testedClassName =
+ "nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt001aTestClass10";
+
+
+ protected void testRun() {
+ EventRequest eventRequest1 = null;
+ String property1 = "ClassPrepareRequest1";
+ ReferenceType testClassReference = null;
+
+ for (int i = 0; ; i++) {
+
+ if (!shouldRunAfterBreakpoint()) {
+ vm.resume();
+ break;
+ }
+
+ display(":::::: case: # " + i);
+
+ switch (i) {
+
+ case 0:
+ testClassReference = (ReferenceType) vm.classesByName(testedClassName).get(0);
+
+ eventRequest1 = setting21ClassPrepareRequest(testClassReference,
+ EventRequest.SUSPEND_NONE, property1);
+
+ display("......waiting for ClassPrepareEvent in expected thread");
+ Event newEvent = eventHandler.waitForRequestedEvent(new EventRequest[]{eventRequest1}, waitTime, true);
+
+ if ( !(newEvent instanceof ClassPrepareEvent)) {
+ setFailedStatus("ERROR: new event is not ClassPrepareEvent");
+ } else {
+
+ String property = (String) newEvent.request().getProperty("number");
+ display(" got new ClassPrepareEvent with property 'number' == " + property);
+
+ if ( !property.equals(property1) ) {
+ setFailedStatus("ERROR: property is not : " + property1);
+ }
+ }
+ break;
+
+ default:
+ throw new Failure("** default case 2 **");
+ }
+ }
+ return;
+ }
+
+ private ClassPrepareRequest setting21ClassPrepareRequest ( ReferenceType testedClass,
+ int suspendPolicy,
+ String property ) {
+ try {
+ display("......setting up ClassPrepareRequest:");
+ display(" class: " + testedClass + "; property: " + property);
+
+ ClassPrepareRequest
+ cpr = eventRManager.createClassPrepareRequest();
+ cpr.putProperty("number", property);
+ cpr.addClassFilter(testedClass);
+ cpr.setSuspendPolicy(suspendPolicy);
+
+ display(" ClassPrepareRequest has been set up");
+ return cpr;
+ } catch ( Exception e ) {
+ throw new Failure("** FAILURE to set up ClassPrepareRequest **");
+ }
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001/TestDescription.java
new file mode 100644
index 00000000000..dc823fdde8a
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001/TestDescription.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the implementation of an object of the type
+ * ClassPrepareRequest.
+ * The test checks up that a result of the method
+ * com.sun.jdi.ClassPrepareRequest.addClassFilter_rt()
+ * complies with its spec:
+ * public void addClassFilter(ReferenceType refType)
+ * Restricts the events generated by this request to be the preparation
+ * of the given reference type and any subtypes.
+ * An event will be generated for any prepared reference type
+ * that can be safely cast to the given reference type.
+ * Parameters: refType - the reference type to filter on.
+ * Throws: InvalidRequestStateException -
+ * if this request is currently enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to be the preparation
+ * of the given reference type and any subtypes.
+ * An event will be generated for any prepared reference type
+ * that can be safely cast to the given reference type.
+ * The test works as follows:
+ * The debugger program - nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt001;
+ * the debuggee program - nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt001a.
+ * Using nsk.jdi.share classes,
+ * the debugger gets the debuggee running on another JavaVM,
+ * creates the object debuggee.VM, and waits for VMStartEvent.
+ * Upon getting the debuggee VM started,
+ * the debugger calls corresponding debuggee.VM methods to get
+ * needed data and to perform checks.
+ * In case of error the test produces the return value 97 and
+ * a corresponding error message(s).
+ * Otherwise, the test is passed and produces
+ * the return value 95 and no message.
+ * COMMENTS:
+ * 4930911 TEST_BUG: filter_rt006 debuggee has a race
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt001
+ * nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001a.java
new file mode 100644
index 00000000000..80f3c2d6232
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001a.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassFilter_rt;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * This class is used as debuggee application for the filter_rt001 JDI test.
+ */
+
+public class filter_rt001a {
+
+ //----------------------------------------------------- templete section
+
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ static ArgumentHandler argHandler;
+ static Log log;
+
+ //-------------------------------------------------- log procedures
+
+ public static void log1(String message) {
+ log.display("**> debuggee: " + message);
+ }
+
+ private static void logErr(String message) {
+ log.complain("**> debuggee: " + message);
+ }
+
+ //====================================================== test program
+ //------------------------------------------------------ common section
+
+ static int exitCode = PASSED;
+
+ static int instruction = 1;
+ static int end = 0;
+ // static int quit = 0;
+ // static int continue = 2;
+ static int maxInstr = 1; // 2;
+
+ static int lineForComm = 2;
+
+ private static void methodForCommunication() {
+ int i1 = instruction;
+ int i2 = i1;
+ int i3 = i2;
+ }
+ //---------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+
+ argHandler = new ArgumentHandler(argv);
+ log = argHandler.createDebugeeLog();
+
+ log1("debuggee started!");
+
+ label0:
+ for (int i = 0; ; i++) {
+
+ if (instruction > maxInstr) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break ;
+ }
+
+ switch (i) {
+
+ //------------------------------------------------------ section tested
+
+ case 0:
+ filter_rt001aTestClass10 obj = new filter_rt001aTestClass10();
+ break;
+
+
+ case 1:
+ filter_rt001aThread1 thread1 = new filter_rt001aThread1("thread1");
+ filter_rt001aThread2 thread2 = new filter_rt001aThread2("thread2");
+
+ log1("new filter_rt001a().run1(thread1);");
+ new filter_rt001a().run1(thread1);
+
+ log1("new filter_rt001a().run1(thread2);");
+ new filter_rt001a().run1(thread2);
+
+ //------------------------------------------------- standard end section
+
+ default:
+ instruction = end;
+ break;
+ }
+ log1("methodForCommunication();");
+ methodForCommunication();
+ if (instruction == end)
+ break;
+ }
+
+ log1("debuggee exits");
+ System.exit(exitCode + PASS_BASE);
+ }
+
+ static Object waitnotifyObj = new Object();
+
+ static int threadStart(Thread t) {
+ synchronized (waitnotifyObj) {
+ t.start();
+ try {
+ waitnotifyObj.wait();
+ } catch ( Exception e) {
+ exitCode = FAILED;
+ logErr(" Exception : " + e );
+ return FAILED;
+ }
+ }
+ return PASSED;
+ }
+
+ public void run1(Thread t) {
+ t.start();
+ try {
+ t.join();
+ } catch ( InterruptedException e ) {
+ }
+ }
+
+}
+
+class filter_rt001aTestClass10{
+ static int var10 = 0;
+}
+class filter_rt001aTestClass11 extends filter_rt001aTestClass10{
+ static int var11 = 0;
+}
+class filter_rt001aThread1 extends Thread {
+
+ String tName = null;
+
+ public filter_rt001aThread1(String threadName) {
+ super(threadName);
+ tName = threadName;
+ }
+
+ public void run() {
+ filter_rt001a.log1(" 'run': enter :: threadName == " + tName);
+ filter_rt001aTestClass11 obj1 = new filter_rt001aTestClass11();
+ filter_rt001a.log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+}
+
+class filter_rt001aTestClass20 {
+ static int var20 = 0;
+}
+class filter_rt001aTestClass21 {
+ static int var21 = 0;
+}
+class filter_rt001aThread2 extends Thread {
+
+ String tName = null;
+
+ public filter_rt001aThread2(String threadName) {
+ super(threadName);
+ tName = threadName;
+ }
+
+ public void run() {
+ filter_rt001a.log1(" 'run': enter :: threadName == " + tName);
+ filter_rt001aTestClass21 obj2 = new filter_rt001aTestClass21();
+ filter_rt001a.log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java
new file mode 100644
index 00000000000..49960940b05
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java
@@ -0,0 +1,540 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassFilter_rt;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type com.sun.jdi.ClassPrepareRequest.addClassFilter_rt() com.sun.jdi.ClassPrepareRequest.addClassFilter_rt()
+ * complies with its spec.
+ *
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to be
+ * the preparation of the given reference type and any subtypes.
+ * The cases to test include re-invocations of the method
+ * addClassFilter() on the same ClassPrepareRequest object.
+ * There are two ClassPrepareRequests to check as follows:
+ * (1) For ClassPrepareRequest2, both invocations are with different
+ * ReferenceTypes restricting one ClassPrepare event to two classes.
+ * The test expects no ClassPrepare event will be received.
+ * (2) For ClassPrepareRequest1, both invocations are with the same
+ * ReferenceType restricting one ClassPrepare event to one class.
+ * The test expects this ClassPrepare event will be received.
+ *
+ * The test works as follows.
+ * - The debugger resumes the debuggee and waits for the BreakpointEvent.
+ * - The debuggee creates class filter objects, to load the Classes to
+ * filter, and invokes the methodForCommunication to be suspended and
+ * to inform the debugger with the event.
+ * - Upon getting the BreakpointEvent, the debugger
+ * - gets ReferenceTypes 1&2 for the Classes to filter,
+ * - sets up two ClassPrepareRequests 1&2,
+ * - double restricts ClassPrepareRequest1 to the RefTypes 1 and 1,
+ * - double restricts ClassPrepareRequest2 to the RefTypes 1 and 2,
+ * - resumes debuggee's main thread, and
+ * - waits for the event.
+ * - The debuggee creates and starts two threads, thread1 and thread2,
+ * first of them will create an object of sub-Class to be filtered,
+ * whereas second will create an object to be not filtered.
+ * - Upon getting the event, the debugger performs the checks required.
+ */
+
+public class filter_rt003 extends TestDebuggerType1 {
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ debuggeeName = "nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt003a";
+ return new filter_rt003().runThis(argv, out);
+ }
+
+ private String testedClassName10 =
+ "nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt003aTestClass10";
+
+ private String testedClassName20 =
+ "nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt003aTestClass20";
+
+
+ protected void testRun() {
+ EventRequest eventRequest1 = null;
+ EventRequest eventRequest2 = null;
+
+ String property1 = "ClassPrepareRequest1";
+ String property2 = "ClassPrepareRequest2";
+
+ ReferenceType testClassReference10 = null;
+ ReferenceType testClassReference20 = null;
+
+ for (int i = 0; ; i++) {
+
+ if (!shouldRunAfterBreakpoint()) {
+ vm.resume();
+ break;
+ }
+
+ display(":::::: case: # " + i);
+ switch (i) {
+
+ case 0:
+ testClassReference10 = (ReferenceType) vm.classesByName(testedClassName10).get(0);
+ testClassReference20 = (ReferenceType) vm.classesByName(testedClassName20).get(0);
+
+ eventRequest1 = setting21ClassPrepareRequest(testClassReference10,
+ EventRequest.SUSPEND_ALL, property1);
+
+ eventRequest2 = setting21ClassPrepareRequest(testClassReference10,
+ EventRequest.SUSPEND_ALL, property2);
+
+ ((ClassPrepareRequest) eventRequest1).addClassFilter(testClassReference10);
+ ((ClassPrepareRequest) eventRequest2).addClassFilter(testClassReference20);
+
+ display("......waiting for ClassPrepareEvent in expected thread");
+ Event newEvent = eventHandler.waitForRequestedEvent(new EventRequest[]{eventRequest1, eventRequest2}, waitTime, true);
+
+ if ( !(newEvent instanceof ClassPrepareEvent)) {
+ setFailedStatus("ERROR: new event is not ClassPrepareEvent");
+ } else {
+
+ String property = (String) newEvent.request().getProperty("number");
+ display(" got new ClassPrepareEvent with propety 'number' == " + property);
+
+ if ( !property.equals(property1) ) {
+ setFailedStatus("ERROR: property is not : " + property1);
+ }
+ }
+ vm.resume();
+ break;
+
+ default:
+ throw new Failure("** default case 1 **");
+ }
+ }
+ return;
+ }
+
+ private ClassPrepareRequest setting21ClassPrepareRequest ( ReferenceType testedClass,
+ int suspendPolicy,
+ String property ) {
+ try {
+ display("......setting up ClassPrepareRequest:");
+ display(" class: " + testedClass + "; property: " + property);
+
+ ClassPrepareRequest
+ cpr = eventRManager.createClassPrepareRequest();
+ cpr.putProperty("number", property);
+ cpr.addClassFilter(testedClass);
+ cpr.setSuspendPolicy(suspendPolicy);
+
+ display(" ClassPrepareRequest has been set up");
+ return cpr;
+ } catch ( Exception e ) {
+ throw new Failure("** FAILURE to set up ClassPrepareRequest **");
+ }
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003/TestDescription.java
new file mode 100644
index 00000000000..e6812a43e44
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003/TestDescription.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the implementation of an object of the type
+ * ClassPrepareRequest.
+ * The test checks up that a result of the method
+ * com.sun.jdi.ClassPrepareRequest.addClassFilter_rt()
+ * complies with its spec:
+ * public void addClassFilter(ReferenceType refType)
+ * Restricts the events generated by this request to be the preparation
+ * of the given reference type and any subtypes.
+ * An event will be generated for any prepared reference type
+ * that can be safely cast to the given reference type.
+ * Parameters: refType - the reference type to filter on.
+ * Throws: InvalidRequestStateException -
+ * if this request is currently enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to be the preparation
+ * of the given reference type and any subtypes.
+ * The cases to test include re-invocations of the method
+ * addClassFilter() on the same ClassPrepareRequest object.
+ * There are two ClassPrepareRequests to check as follows:
+ * (1) For ClassPrepareRequest2, both invocations are with different
+ * ReferenceTypes restricting one ClassPrepare event to two classes.
+ * The test expects no ClassPrepare event will be received.
+ * (2) For ClassPrepareRequest1, both invocations are with the same
+ * ReferenceType restricting one ClassPrepare event to one class.
+ * The test expects this ClassPrepare event will be received.
+ * The test works as follows:
+ * The debugger program - nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt003;
+ * the debuggee program - nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt003a.
+ * Using nsk.jdi.share classes,
+ * the debugger gets the debuggee running on another JavaVM,
+ * creates the object debuggee.VM, and waits for VMStartEvent.
+ * Upon getting the debuggee VM started,
+ * the debugger calls corresponding debuggee.VM methods to get
+ * needed data and to perform checks.
+ * In case of error the test produces the return value 97 and
+ * a corresponding error message(s).
+ * Otherwise, the test is passed and produces
+ * the return value 95 and no message.
+ * COMMENTS:
+ * 4930911 TEST_BUG: filter_rt006 debuggee has a race
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt003
+ * nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt003a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt003
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003a.java
new file mode 100644
index 00000000000..291d0a9f075
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003a.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassFilter_rt;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * This class is used as debuggee application for the filter_rt003 JDI test.
+ */
+
+public class filter_rt003a {
+
+ //----------------------------------------------------- templete section
+
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ static ArgumentHandler argHandler;
+ static Log log;
+
+ //-------------------------------------------------- log procedures
+
+ public static void log1(String message) {
+ log.display("**> debuggee: " + message);
+ }
+
+ private static void logErr(String message) {
+ log.complain("**> debuggee: " + message);
+ }
+
+ //====================================================== test program
+ //------------------------------------------------------ common section
+
+ static int exitCode = PASSED;
+
+ static int instruction = 1;
+ static int end = 0;
+ // static int quit = 0;
+ // static int continue = 2;
+ static int maxInstr = 1; // 2;
+
+ static int lineForComm = 2;
+
+ private static void methodForCommunication() {
+ int i1 = instruction;
+ int i2 = i1;
+ int i3 = i2;
+ }
+ //---------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+
+ argHandler = new ArgumentHandler(argv);
+ log = argHandler.createDebugeeLog();
+
+ log1("debuggee started!");
+
+ label0:
+ for (int i = 0; ; i++) {
+
+ if (instruction > maxInstr) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break ;
+ }
+
+ switch (i) {
+
+ //------------------------------------------------------ section tested
+
+ case 0:
+ filter_rt003aTestClass10 obj1 = new filter_rt003aTestClass10();
+ filter_rt003aTestClass20 obj2 = new filter_rt003aTestClass20();
+ break;
+
+
+ case 1:
+ filter_rt003aThread1 thread1 = new filter_rt003aThread1("thread1");
+ filter_rt003aThread2 thread2 = new filter_rt003aThread2("thread2");
+
+ log1("new filter_rt003a().run1(thread1);");
+ new filter_rt003a().run1(thread1);
+
+ log1("new filter_rt003a().run1(thread2);");
+ new filter_rt003a().run1(thread2);
+
+ //------------------------------------------------- standard end section
+
+ default:
+ instruction = end;
+ break;
+ }
+ log1("methodForCommunication();");
+ methodForCommunication();
+ if (instruction == end)
+ break;
+ }
+
+ log1("debuggee exits");
+ System.exit(exitCode + PASS_BASE);
+ }
+
+ static Object waitnotifyObj = new Object();
+
+ static int threadStart(Thread t) {
+ synchronized (waitnotifyObj) {
+ t.start();
+ try {
+ waitnotifyObj.wait();
+ } catch ( Exception e) {
+ exitCode = FAILED;
+ logErr(" Exception : " + e );
+ return FAILED;
+ }
+ }
+ return PASSED;
+ }
+
+ public void run1(Thread t) {
+ t.start();
+ try {
+ t.join();
+ } catch ( InterruptedException e ) {
+ }
+ }
+
+}
+
+class filter_rt003aTestClass10{
+ static int var10 = 0;
+}
+class filter_rt003aTestClass11 extends filter_rt003aTestClass10{
+ static int var11 = 0;
+}
+class filter_rt003aThread1 extends Thread {
+
+ String tName = null;
+
+ public filter_rt003aThread1(String threadName) {
+ super(threadName);
+ tName = threadName;
+ }
+
+ public void run() {
+ filter_rt003a.log1(" 'run': enter :: threadName == " + tName);
+ filter_rt003aTestClass11 obj1 = new filter_rt003aTestClass11();
+ filter_rt003a.log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+}
+
+class filter_rt003aTestClass20 {
+ static int var20 = 0;
+}
+class filter_rt003aTestClass21 {
+ static int var21 = 0;
+}
+class filter_rt003aThread2 extends Thread {
+
+ String tName = null;
+
+ public filter_rt003aThread2(String threadName) {
+ super(threadName);
+ tName = threadName;
+ }
+
+ public void run() {
+ filter_rt003a.log1(" 'run': enter :: threadName == " + tName);
+ filter_rt003aTestClass21 obj2 = new filter_rt003aTestClass21();
+ filter_rt003a.log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001.java
new file mode 100644
index 00000000000..937a5ea2531
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassFilter_s;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type
+ * ClassPrepareRequest.
+ *
+ * The test checks that results of the method
+ * com.sun.jdi.ClassPrepareRequest.addClassFilter(String)
+ * complies with its spec.
+ *
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those
+ * whose location is in a class
+ * whose name matches a restricted regular expression.
+ * The cases to check include both a pattern that begin with '*'
+ * one that end with '*'.
+ *
+ * The test works as follows.
+ * - The debugger
+ * - creates two class filter objects,
+ * first one using a pattern that begin with '*', and
+ * second one using a pattern that end with '*'
+ * to filter ClassPrepareEvents in two debuggee's tested threads,
+ * - sets up two ClassPrepareRequests,
+ * - resumes the debuggee, and
+ * - waits for expected ClassPrepareEvents.
+ * - The debuggee creates and starts two threads
+ * whose 'run' methods create objects of ClassTypes needed
+ * to generate Events and to test the filters.
+ * - Upon getting the events, the debugger performs the checks required.
+ */
+
+public class filter_s001 extends TestDebuggerType1 {
+
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ debuggeeName = "nsk.jdi.ClassPrepareRequest.addClassFilter_s.filter_s001a";
+ return new filter_s001().runThis(argv, out);
+ }
+
+ private String testedClassName1 = "*TestClass11";
+ private String testedClassName2 =
+ "nsk.jdi.ClassPrepareRequest.addClassFilter_s.Thread2filter_s001a*";
+
+ private String className1 = "TestClass11";
+ private String className2 =
+ "nsk.jdi.ClassPrepareRequest.addClassFilter_s.Thread2filter_s001a";
+
+ protected void testRun() {
+ EventRequest eventRequest1 = null;
+ EventRequest eventRequest2 = null;
+
+ String property1 = "ClassPrepareRequest1";
+ String property2 = "ClassPrepareRequest2";
+
+ Event newEvent = null;
+
+ for (int i = 0; ; i++) {
+
+ if (!shouldRunAfterBreakpoint()) {
+ vm.resume();
+ break;
+ }
+
+ display(":::::: case: # " + i);
+
+ switch (i) {
+
+ case 0:
+ eventRequest1 = setting22ClassPrepareRequest(testedClassName1,
+ EventRequest.SUSPEND_ALL, property1);
+
+ display("......waiting for ClassPrepareEvent in expected thread");
+ newEvent = eventHandler.waitForRequestedEvent(new EventRequest[]{eventRequest1}, waitTime, true);
+
+ if ( !(newEvent instanceof ClassPrepareEvent)) {
+ setFailedStatus("ERROR: new event is not ClassPrepareEvent");
+ } else {
+ String str = ((ClassPrepareEvent)newEvent).referenceType().name();
+ if (!str.endsWith(className1)) {
+ setFailedStatus("Received ClassPrepareEvent for unexpected class: \n\t" + str);
+ } else {
+ display("Received ClassPrepareEvent for expected class: \n\t" + str);
+ }
+
+ String property = (String) newEvent.request().getProperty("number");
+ display(" got new ClassPrepareEvent with property 'number' == " + property);
+
+ if ( !property.equals(property1) ) {
+ setFailedStatus("ERROR: property is not : " + property1);
+ }
+ }
+
+ vm.resume();
+ break;
+
+ case 1:
+ eventRequest2 = setting22ClassPrepareRequest(testedClassName2,
+ EventRequest.SUSPEND_ALL, property2);
+
+ display("......waiting for ClassPrepareEvent in expected thread");
+ newEvent = eventHandler.waitForRequestedEvent(new EventRequest[]{eventRequest2}, waitTime, true);
+
+ if ( !(newEvent instanceof ClassPrepareEvent)) {
+ setFailedStatus("ERROR: new event is not ClassPrepareEvent");
+ } else {
+
+ String str = ((ClassPrepareEvent)newEvent).referenceType().name();
+ if (!str.endsWith(className2)) {
+ setFailedStatus("Received ClassPrepareEvent for unexpected class: \n\t" + str);
+ } else {
+ display("Received ClassPrepareEvent for expected class: \n\t" + str);
+ }
+
+ String property = (String) newEvent.request().getProperty("number");
+ display(" got new ClassPrepareEvent with property 'number' == " + property);
+
+ if ( !property.equals(property2) ) {
+ setFailedStatus("ERROR: property is not : " + property2);
+ }
+ }
+ vm.resume();
+ break;
+
+ default:
+ throw new Failure("** default case 2 **");
+ }
+ }
+ return;
+ }
+
+ private ClassPrepareRequest setting22ClassPrepareRequest ( String testedClass,
+ int suspendPolicy,
+ String property ) {
+ try {
+ display("......setting up ClassPrepareRequest:");
+ display(" class: " + testedClass + "; property: " + property);
+
+ ClassPrepareRequest
+ cpr = eventRManager.createClassPrepareRequest();
+ cpr.putProperty("number", property);
+ cpr.addClassFilter(testedClass);
+ cpr.setSuspendPolicy(suspendPolicy);
+
+ display(" ClassPrepareRequest has been set up");
+ return cpr;
+ } catch ( Exception e ) {
+ throw new Failure("** FAILURE to set up ClassPrepareRequest **");
+ }
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001/TestDescription.java
new file mode 100644
index 00000000000..c4a052e8bd9
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001/TestDescription.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the implementation of an object of the type
+ * ClassPrepareRequest.
+ * The test checks up that a result of the method
+ * com.sun.jdi.ClassPrepareRequest.addClassFilter_s()
+ * complies with its spec:
+ * public void addClassFilter(String classPattern)
+ * Restricts the events generated by this request to those whose location is in a class
+ * whose name matches a restricted regular expression.
+ * Regular expressions are limited to exact matches and patterns that
+ * begin with '*' or end with '*'; for example, "*.Foo" or "java.*".
+ * Parameters: classPattern - the pattern String to filter for.
+ * Throws: InvalidRequestStateException -
+ * if this request is currently enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ * The test checks up on the following assertion:
+ * Restricts the events generated by this request to those
+ * whose location is in a class
+ * whose name matches a restricted regular expression.
+ * The test works as follows:
+ * The debugger program - nsk.jdi.ClassPrepareRequest.addClassFilter_s.filter_s001;
+ * the debuggee program - nsk.jdi.ClassPrepareRequest.addClassFilter_s.filter_s001a.
+ * Using nsk.jdi.share classes,
+ * the debugger gets the debuggee running on another JavaVM,
+ * creates the object debuggee.VM, and waits for VMStartEvent.
+ * Upon getting the debuggee VM started,
+ * the debugger calls corresponding debuggee.VM methods to get
+ * needed data and to perform checks.
+ * In case of error the test produces the return value 97 and
+ * a corresponding error message(s).
+ * Otherwise, the test is passed and produces
+ * the return value 95 and no message.
+ * COMMENTS:
+ * The test was modified to fix the bug:
+ * 4627990 JDI testcase filter_s001 failing
+ * 4930911 TEST_BUG: filter_rt006 debuggee has a race
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.ClassPrepareRequest.addClassFilter_s.filter_s001
+ * nsk.jdi.ClassPrepareRequest.addClassFilter_s.filter_s001a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.ClassPrepareRequest.addClassFilter_s.filter_s001
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001a.java
new file mode 100644
index 00000000000..f96143acfb6
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001a.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassFilter_s;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * This class is used as debuggee application for the filter_s001 JDI test.
+ */
+
+public class filter_s001a {
+
+ //----------------------------------------------------- templete section
+
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ static ArgumentHandler argHandler;
+ static Log log;
+
+ //-------------------------------------------------- log procedures
+
+ public static void log1(String message) {
+ log.display("**> debuggee: " + message);
+ }
+
+ private static void logErr(String message) {
+ log.complain("**> debuggee: " + message);
+ }
+
+ //====================================================== test program
+ //------------------------------------------------------ common section
+
+ static int exitCode = PASSED;
+
+ static int instruction = 1;
+ static int end = 0;
+ // static int quit = 0;
+ // static int continue = 2;
+ static int maxInstr = 2; // 2;
+
+ static int lineForComm = 2;
+
+ private static void methodForCommunication() {
+ int i1 = instruction;
+ int i2 = i1;
+ int i3 = i2;
+ }
+ //---------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+
+ argHandler = new ArgumentHandler(argv);
+ log = argHandler.createDebugeeLog();
+
+ log1("debuggee started!");
+
+ label0:
+ for (int i = 0; ; i++) {
+
+ log1("methodForCommunication();");
+ methodForCommunication();
+ if (instruction == end)
+ break;
+
+ if (instruction > maxInstr) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break ;
+ }
+
+ switch (i) {
+
+//------------------------------------------------------ section tested
+
+ case 0:
+ Thread1filter_s001a thread1 = new Thread1filter_s001a("thread1");
+ log1("new filter_s001a().run1(thread1);");
+ new filter_s001a().run1(thread1);
+ break;
+
+ case 1:
+ Thread2filter_s001a thread2 = new Thread2filter_s001a("thread2");
+ log1("new filter_s001a().run1(thread2);");
+ new filter_s001a().run1(thread2);
+
+//------------------------------------------------- standard end section
+
+ default:
+ instruction = end;
+ break;
+ }
+ }
+
+ log1("debuggee exits");
+ System.exit(exitCode + PASS_BASE);
+ }
+
+ static Object waitnotifyObj = new Object();
+
+ static int threadStart(Thread t) {
+ synchronized (waitnotifyObj) {
+ t.start();
+ try {
+ waitnotifyObj.wait();
+ } catch ( Exception e) {
+ exitCode = FAILED;
+ logErr(" Exception : " + e );
+ return FAILED;
+ }
+ }
+ return PASSED;
+ }
+
+ public void run1(Thread t) {
+ t.start();
+ try {
+ t.join();
+ } catch ( InterruptedException e ) {
+ }
+ }
+
+}
+
+class Thread1filter_s001a extends Thread {
+
+ class TestClass10{
+ int var10 = 0;
+ }
+ class TestClass11 extends TestClass10{
+ int var11 = 0;
+ }
+
+ String tName = null;
+
+ public Thread1filter_s001a(String threadName) {
+ super(threadName);
+ tName = threadName;
+ }
+
+ public void run() {
+ filter_s001a.log1(" 'run': enter :: threadName == " + tName);
+ TestClass11 obj1 = new TestClass11();
+ filter_s001a.log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+}
+
+class Thread2filter_s001a extends Thread {
+
+ String tName = null;
+
+ public Thread2filter_s001a(String threadName) {
+ super(threadName);
+ tName = threadName;
+ }
+
+ public void run() {
+ filter_s001a.log1(" 'run': enter :: threadName == " + tName);
+ filter_s001aTestClass21 obj2 = new filter_s001aTestClass21();
+ filter_s001a.log1(" 'run': exit :: threadName == " + tName);
+ return;
+ }
+}
+
+class filter_s001aTestClass21 {
+ int var21 = 0;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java
new file mode 100644
index 00000000000..68649fb18e9
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java
@@ -0,0 +1,537 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassPrepareRequest.addClassFilter_s;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type com.sun.jdi.ClassPrepareRequest.addClassFilter_s() com.sun.jdi.ClassType.allInterfaces() com.sun.jdi.ClassType.concreteMethodByName() com.sun.jdi.ClassType.concreteMethodByName(String, String) Method
+ * that matches the given name and signature or null if there is
+ * no match. No exception is expected.
+ * All variants of argument values are placed in parameters array.
+ * Also, this array contains an expected return value for every pair of
+ * arguments values: null - return value of concreteMethodByName()null
+ * "T" - return value of concreteMethodByName()null
+ */
+
+public class method002 {
+
+ private final static String prefix = "nsk.jdi.ClassType.concreteMethodByName.";
+ private final static String debuggerName = prefix + "method002";
+ private final static String debugeeName = debuggerName + "a";
+
+ public final static String SGNL_READY = "ready";
+ public final static String SGNL_QUIT = "quit";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+
+ private ClassType testedClass;
+
+ private String [][] parameters = {
+// methodName signature result
+ {"justMethod", "(I)I", "T"},
+ {"justMethod", null, null},
+ {null, "(I)I", null},
+ {null, null, null},
+ {"", "", null}
+ };
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ method002 thisTest = new method002();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ thisTest.execTest();
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() {
+
+ testedClass = (ClassType )debugee.classByName(debugeeName);
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ Method method;
+ for (int i = 0; i < parameters.length; i ++) {
+ display("invoking concreteMethodByName(\"" + parameters[i][0]
+ + "\",\"" + parameters[i][1] + "\")");
+ try {
+ method = testedClass.concreteMethodByName(parameters[i][0],
+ parameters[i][1]);
+ if (parameters[i][2] != null) {
+ if (method == null) {
+ complain("Method : " + method);
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("Method : " + method);
+ }
+ } else {
+ if (method == null) {
+ display("Method : " + method);
+ } else {
+ complain("Method : " + method);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ }
+ } catch(NullPointerException e) {
+ display("!!!expected NullPointerException");
+ } catch(Exception e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ display("");
+ }
+
+ display("");
+ display("=============");
+ display("TEST FINISHES\n");
+
+ debugee.resume();
+ debugee.quit();
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/concreteMethodByName/method002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/concreteMethodByName/method002/TestDescription.java
new file mode 100644
index 00000000000..88a7b0f333d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/concreteMethodByName/method002/TestDescription.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassType/concreteMethodByName/method002.
+ * VM Testbase keywords: [jpda, jdi]
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test checks up the method
+ * com.sun.jdi.ClassType.concreteMethodByName(String, String)
+ * for boundary value of parameters.
+ * In any cases it is expected, this method will return either the method
+ * that matches the given name and signature or null if there is no match.
+ * No exception is expected.
+ * COMMENTS:
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @build nsk.jdi.ClassType.concreteMethodByName.method002
+ * nsk.jdi.ClassType.concreteMethodByName.method002a
+ * @run main/othervm PropertyResolvingWrapper
+ * nsk.jdi.ClassType.concreteMethodByName.method002
+ * -verbose
+ * -arch=${os.family}-${os.simpleArch}
+ * -waittime=5
+ * -debugee.vmkind=java
+ * -transport.address=dynamic
+ * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
+ */
+
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/concreteMethodByName/method002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/concreteMethodByName/method002a.java
new file mode 100644
index 00000000000..b1af468bd5e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/concreteMethodByName/method002a.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.concreteMethodByName;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * method002a is deugee's part of the method002.
+ */
+public class method002a {
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ Log log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(method002.SGNL_READY);
+ String instr = pipe.readln();
+ if (instr.equals(method002.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int justMethod(int val) {
+ return val;
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/interfaces/interfaces001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/interfaces/interfaces001.java
new file mode 100644
index 00000000000..429556ceffe
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/interfaces/interfaces001.java
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2001, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.interfaces;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import java.util.*;
+import java.io.*;
+
+/**
+ * The test for the implementation of an object of the type com.sun.jdi.ClassType.interfaces() com.sun.jdi.ClassType.invokeMethod() invokemethod002a is deugee's part of the invokemethod002.
+ */
+public class invokemethod002a {
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 45;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ Log log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(invokemethod002.SGNL_READY);
+ String instr = pipe.readln(); // brkpLineNumber
+ if (instr.equals(invokemethod002.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+
+ // methods is invoked by debugger
+ private static boolean methodBOOLParam(boolean value) {
+ return value;
+ }
+
+ private static byte methodBYTEParam(byte value) {
+ return value;
+ }
+
+ private static char methodCHARParam(char value) {
+ return value;
+ }
+
+ private static double methodDOUBLEParam(double value) {
+ return value;
+ }
+
+ private static float methodFLOATParam(float value) {
+ return value;
+ }
+
+ private static int methodINTParam(int value) {
+ return value;
+ }
+
+ private static long methodLONGParam(long value) {
+ return value;
+ }
+
+ private static short methodSHORTParam(short value) {
+ return value;
+ }
+
+ private static String methodOBJParam(String value) {
+ return value;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod003.java
new file mode 100644
index 00000000000..d51b969e985
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod003.java
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.invokeMethod;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * Test checks up the following assertions: IllegalArgumentException is thrown if private,
+ * protected and public methods. In this case
+ * no exceptions are expected.invokemethod003a is deugee's part of the invokemethod003.
+ */
+public class invokemethod003a {
+
+ public final static String anotherClassName = "invokemethod003b";
+ public final static String class2Check = "invokemethod003Child";
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 50;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ Log log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ invokemethod003Child child = new invokemethod003Child();
+ invokemethod003b imb = new invokemethod003b();
+ pipe.println(invokemethod003.SGNL_READY);
+
+ String instr = pipe.readln(); // brkpLineNumber
+ if (instr.equals(invokemethod003.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static long publicFromParent(int one, int two, int three) {
+ return one + two + three;
+ }
+
+ protected static long protectFromParent(int one, int two, int three) {
+ return one + two + three;
+ }
+
+ private static long privateFromParent(int one, int two, int three) {
+ return one + two + three;
+ }
+}
+
+class invokemethod003Child extends invokemethod003a {
+ invokemethod003Child() {
+ }
+
+ public static long fromChild(int one, int two, int three) {
+ return one + two + three;
+ }
+}
+
+class invokemethod003b {
+ public void run() {
+ int i = 1;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod004.java
new file mode 100644
index 00000000000..a2bfcffd5aa
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod004.java
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.invokeMethod;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * Test checks up the following assertion: invokemethod004a is deugee's part of the invokemethod004.
+ */
+public class invokemethod004a {
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 48;
+ public final static String testException = "java.lang.NullPointerException";
+
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ Log log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(invokemethod004.SGNL_READY);
+ String instr = pipe.readln();
+ log.display("breakpoint line"); // brkpLineNumber
+ instr = pipe.readln();
+ if (instr.equals(invokemethod004.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static void throwNPE() {
+ Object obj = null;
+ String tmp = obj.toString();
+ }
+
+ protected static void throwCaughtNPE() {
+ Object obj = null;
+ try {
+ String tmp = obj.toString();
+ } catch (NullPointerException e) {
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod005.java
new file mode 100644
index 00000000000..bedc446ec84
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod005.java
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.invokeMethod;
+
+import nsk.share.*;
+import nsk.share.jdi.*;
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import java.util.*;
+import java.io.*;
+import java.lang.reflect.Array;
+
+/**
+ * Test checks up the following assertion:
+ * Primitive arguments must be either assignment compatible with
+ * the argument type or must be convertible to the argument type
+ * without loss of information.
+ * for every primitive type
+ */
+
+public class invokemethod005 extends ValueConversionDebugger {
+
+ private static class TestedMethodData {
+ public String methodName;
+ public ValueType methodType;
+
+ public TestedMethodData(String methodName, ValueType methodType) {
+ this.methodName = methodName;
+ this.methodType = methodType;
+ }
+ }
+
+ private ClassType testedClass;
+
+ private ThreadReference thread;
+
+ private final static TestedMethodData [] methods2Invoke = {
+ new TestedMethodData("methodBYTEParam", BYTE),
+ new TestedMethodData("methodCHARParam", CHAR),
+ new TestedMethodData("methodDOUBLEParam", DOUBLE),
+ new TestedMethodData("methodFLOATParam", FLOAT),
+ new TestedMethodData("methodINTParam", INT),
+ new TestedMethodData("methodLONGParam", LONG),
+ new TestedMethodData("methodSHORTParam", SHORT)
+ };
+
+ private static byte [] byteParamValues =
+ {Byte.MIN_VALUE,
+ -1,
+ 0,
+ 1,
+ Byte.MAX_VALUE};
+ private static char [] charParamValues =
+ {Character.MIN_VALUE,
+ Character.MAX_VALUE};
+ private static double [] doubleParamValues =
+ {Double.NEGATIVE_INFINITY,
+ -1.5D,
+ -1.0D,
+ -0.0D,
+ +0.0D,
+ Double.MIN_VALUE,
+ 1.0D,
+ 1.5D,
+ Double.MAX_VALUE,
+ Double.POSITIVE_INFINITY};
+ private static float [] floatParamValues =
+ {Float.NEGATIVE_INFINITY,
+ -1.5F,
+ -1.0F,
+ -0.0F,
+ +0.0F,
+ Float.MIN_VALUE,
+ 1.0F,
+ 1.5F,
+ Float.MAX_VALUE,
+ Float.POSITIVE_INFINITY};
+ private static int [] intParamValues =
+ {Integer.MIN_VALUE,
+ -1,
+ 0,
+ 1,
+ 1234567890,
+ Integer.MAX_VALUE};
+ private static long [] longParamValues =
+ {Long.MIN_VALUE,
+ -1L,
+ 0L,
+ 1L,
+ 1234567890123456789L,
+ Long.MAX_VALUE};
+ private static short [] shortParamValues =
+ {Short.MIN_VALUE,
+ -1,
+ 0,
+ 1,
+ Short.MAX_VALUE};
+
+ protected String debuggeeClassName() {
+ return invokemethod005a.class.getName();
+ }
+
+ public static void main(String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+ return new invokemethod005().runIt(argv, out);
+ }
+
+ protected void doTest() {
+ initDefaultBreakpoint();
+
+ BreakpointEvent brkpEvent = forceBreakpoint();
+
+ testedClass = (ClassType )debuggee.classByName(debuggeeClassNameWithoutArgs());
+
+ thread = brkpEvent.thread();
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ PrimitiveValue value = null;
+ Listinvokemethod005a is deugee's part of the invokemethod005.
+ */
+public class invokemethod005a extends AbstractJDIDebuggee {
+
+ public static void main (String args[]) {
+ new invokemethod005a().doTest(args);
+ }
+
+ // methods is invoked by debugger
+ private static boolean methodBOOLParam(boolean value) {
+ return value;
+ }
+
+ private static byte methodBYTEParam(byte value) {
+ return value;
+ }
+
+ private static char methodCHARParam(char value) {
+ return value;
+ }
+
+ private static double methodDOUBLEParam(double value) {
+ return value;
+ }
+
+ private static float methodFLOATParam(float value) {
+ return value;
+ }
+
+ private static int methodINTParam(int value) {
+ return value;
+ }
+
+ private static long methodLONGParam(long value) {
+ return value;
+ }
+
+ private static short methodSHORTParam(short value) {
+ return value;
+ }
+
+ private static String methodOBJParam(String value) {
+ return value;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod006.java
new file mode 100644
index 00000000000..494f54f9de9
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod006.java
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.invokeMethod;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * Test checks up that NullPointerException will be thrown in
+ * the following cases: invokemethod006a is deugee's part of the invokemethod006.
+ */
+public class invokemethod006a {
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 46;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ Log log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(invokemethod006.SGNL_READY);
+ String instr = pipe.readln();
+ log.display("breakpoint line"); // brkpLineNumber
+ instr = pipe.readln();
+ if (instr.equals(invokemethod006.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int justMethod(int val) {
+ return val;
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod007.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod007.java
new file mode 100644
index 00000000000..5df33317b94
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod007.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.invokeMethod;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ *
+ * The test checks up the method com.sun.jdi.ClassType.invokeMethod()
+ *
+ * Test checks up the following assertion:
+ * ...all threads in the target VM are resumed while the method is
+ * being invoked if they were previously suspended by an event or by
+ * VirtualMachine.suspend() or ThreadReference.suspend().
+ *
+ * This checking is implemented for three cases:
+ * - when the tested thread is suspended by ThreadReference.suspend();
+ * - when the tested thread is suspended by VirtualMachine.suspend();
+ * - when the tested thread is suspended by an event.
+ */
+
+public class invokemethod007 {
+
+ private final static String prefix = "nsk.jdi.ClassType.invokeMethod.";
+ private final static String debuggerName = prefix + "invokemethod007";
+ private final static String debugeeName = debuggerName + "a";
+
+ public final static String SGNL_READY = "ready";
+ public final static String SGNL_QUIT = "quit";
+ public final static String SGNL_STRTHRD = "start_thread";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+
+ private ClassType testedClass;
+ private ThreadReference thread;
+
+ class TestRuntimeException extends RuntimeException {
+ TestRuntimeException(String msg) {
+ super("TestRuntimeException: " + msg);
+ }
+ }
+
+ public final static String method2Invoke = "invokedMethod";
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ invokemethod007 thisTest = new invokemethod007();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ thisTest.execTest();
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() {
+
+ debugee.VM().suspend();
+ testedClass = (ClassType )debugee.classByName(debugeeName);
+
+ BreakpointRequest brkp = debugee.makeBreakpoint(testedClass,
+ invokemethod007a.brkpMethodName,
+ invokemethod007a.brkpLineNumber);
+ brkp.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
+ brkp.enable();
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ Value retValue;
+ Listinvokemethod007a is deugee's part of the invokemethod007.
+ */
+public class invokemethod007a {
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 70;
+ public final static String testedThread = "im007aThread01";
+
+ public static Log log;
+ public static long waitTime;
+ private static IOPipe pipe;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ waitTime = argHandler.getWaitTime() * 60000;
+ pipe = argHandler.createDebugeeIOPipe(log);
+ im007aThread01 thread = null;
+ pipe.println(invokemethod007.SGNL_READY);
+
+ String instr = pipe.readln();
+ while (!instr.equals(invokemethod007.SGNL_QUIT)) {
+
+ // create new thread and start it
+ if (instr.equals(invokemethod007.SGNL_STRTHRD)) {
+ thread = new im007aThread01("im007aThread01");
+ synchronized(im007aThread01.waitStarting) {
+ thread.start();
+ try {
+ im007aThread01.waitStarting.wait(waitTime);
+ log.display("checked thread started");
+ } catch (InterruptedException e) {
+ throw new Failure("Unexpected InterruptedException while waiting for checked thread start.");
+ }
+ }
+ }
+ log.display("sending ready signal...");
+ pipe.println(invokemethod007.SGNL_READY);
+ log.display("waiting signal from debugger..."); // brkpLineNumber
+ instr = pipe.readln(); // this is a line for breakpoint
+
+ if (thread.isAlive()) {
+ log.display("waiting for join of : " + thread.getName());
+ try {
+ thread.join(waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("Unexpected InterruptedException while waiting for join of " + thread.getName());
+ }
+ if (thread.isAlive()) {
+ try {
+ thread.interrupt();
+ } catch (SecurityException e) {
+ throw new Failure("Cannot interrupt checked thread.");
+ }
+ }
+ }
+ }
+
+ if (instr.equals(invokemethod007.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static long invokedMethod() {
+ log.display("invokedMethod> starting...");
+ try {
+ synchronized(im007aThread01.waitFinishing) {
+ synchronized(im007aThread01.waitInvoking) {
+ log.display("invokedMethod> notifying to thread...");
+ im007aThread01.waitInvoking.notifyAll();
+ }
+
+ log.display("invokedMethod> waiting for thread's response...");
+ long startTime = System.currentTimeMillis();
+ im007aThread01.waitFinishing.wait(waitTime);
+ return System.currentTimeMillis() - startTime;
+ }
+ } catch (InterruptedException e) {
+ log.display("invokedMethod> it was interrupted.");
+ }
+ return waitTime + 1;
+ }
+}
+
+class im007aThread01 extends Thread {
+ public static Object waitInvoking = new Object();
+ public static Object waitStarting = new Object();
+ public static Object waitFinishing = new Object();
+
+ im007aThread01(String threadName) {
+ super(threadName);
+ }
+
+ public void run() {
+ synchronized(waitInvoking) {
+ synchronized(waitStarting) {
+ waitStarting.notifyAll();
+ }
+
+ invokemethod007a.log.display(getName() + "> waiting for the invoked method...");
+ try {
+ long startTime = System.currentTimeMillis();
+ waitInvoking.wait(invokemethod007a.waitTime);
+ if ((System.currentTimeMillis() - startTime) < invokemethod007a.waitTime) {
+ invokemethod007a.log.display(getName() + "> got a response from the invoked method");
+ } else {
+ invokemethod007a.log.display(getName() + "*** no response from invoked method");
+ }
+ } catch (Exception e) {
+ invokemethod007a.log.display(getName() + e);
+ }
+ }
+ synchronized(waitFinishing) {
+ invokemethod007a.log.display(getName() + "> notifying the invoked method...");
+ waitFinishing.notifyAll();
+ }
+ invokemethod007a.log.display(getName() + "> thread finished");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod008.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod008.java
new file mode 100644
index 00000000000..b1125293910
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod008.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.invokeMethod;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ *
+ * The test checks up the method com.sun.jdi.ClassType.invokeMethod()
+ *
+ * Test checks up the following assertion:
+ * If the target VM is disconnected during the invoke (for example,
+ * through VirtualMachine.dispose()) the method invocation continues.
+ */
+
+public class invokemethod008 {
+
+ private final static String prefix = "nsk.jdi.ClassType.invokeMethod.";
+ private final static String debuggerName = prefix + "invokemethod008";
+ private final static String debugeeName = debuggerName + "a";
+
+ public final static String SGNL_READY = "ready";
+ public final static String SGNL_QUIT = "quit";
+ public final static String SGNL_FINISH = "finish";
+ public final static String SGNL_ABORT = "abort";
+
+ public static int exitStatus;
+ public static Log log;
+ public static Debugee debugee;
+ public static long waitTime;
+ private static boolean isAborted = false;
+
+ private ClassType testedClass;
+ public final static String method2Invoke = "justMethod";
+
+ public static void display(String msg) {
+ log.display(msg);
+ }
+
+ public static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ invokemethod008 thisTest = new invokemethod008();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Failure e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ if (!isAborted) {
+ debugee.resume();
+ debugee.quit();
+ }
+ }
+
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure{
+
+ debugee.VM().suspend();
+ testedClass = (ClassType )debugee.classByName(debugeeName);
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ InvokingThread invokeThrd = new InvokingThread();
+ invokeThrd.start();
+
+ // waiting READY signal from invoked method
+ display("\nwaiting for signal \""
+ + SGNL_READY
+ + "\" from the invoked method");
+ debugee.receiveExpectedSignal(SGNL_READY);
+
+ display("\n" + method2Invoke + " has been invoked. Trying to dispose debugee's VM");
+
+ AbortingThread abortingThrd = new AbortingThread();
+ abortingThrd.start();
+
+ debugee.VM().dispose();
+ invokeThrd.waitVMDisconnect();
+
+ try {
+ invokeThrd.join();
+ } catch(InterruptedException e) {
+ throw new Failure("unexpected " + e);
+ }
+
+ if (isAborted) {
+ complain("Debugee's VM disposing hung. Invoking was aborted!!!");
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("\nVirtual machine has been disposed");
+ display("sending signal \"" + SGNL_FINISH + "\" to the invoked method");
+ debugee.sendSignal(SGNL_FINISH);
+ }
+
+ display("\n=============");
+ display("TEST FINISHES\n");
+ }
+
+ private BreakpointEvent waitForBreakpoint(BreakpointRequest brkp) {
+ Event event = null;
+ BreakpointEvent brkpEvent;
+
+ try {
+ event = debugee.waitingEvent(brkp, waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("unexpected " + e);
+ }
+
+ if (!(event instanceof BreakpointEvent )) {
+ throw new Failure("BreakpointEvent didn't arrive");
+ }
+
+ brkpEvent = (BreakpointEvent )event;
+ return brkpEvent;
+ }
+
+
+ class InvokingThread extends Thread {
+ volatile boolean isNotified = false;
+
+ public void run() {
+ display("");
+ BreakpointRequest brkp = debugee.setBreakpoint(testedClass,
+ invokemethod008a.brkpMethodName,
+ invokemethod008a.brkpLineNumber);
+ debugee.resume();
+
+ debugee.sendSignal("");
+
+ BreakpointEvent brkpEvent = waitForBreakpoint(brkp);
+ ThreadReference thread = brkpEvent.thread();
+
+ Value retValue;
+ Listinvokemethod008a is deugee's part of the invokemethod008.
+ */
+public class invokemethod008a {
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 51;
+ private static Log log;
+ private static IOPipe pipe;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(invokemethod008.SGNL_READY);
+
+ String instr = pipe.readln();
+ // the below line is a breakpoint.
+ // Debugger will invoke justMethod().
+ instr = pipe.readln(); // brkpLineNumber
+ if (instr.equals(invokemethod008.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int justMethod() {
+ try {
+ pipe.println(invokemethod008.SGNL_READY);
+ log.display("invoked_method:: waiting response from debugger...");
+ String instr = pipe.readln();
+ if (instr.equals(invokemethod008.SGNL_FINISH)) {
+ log.display("invoked_method:: completed succesfully.");
+ return Consts.TEST_PASSED;
+ } else if (instr.equals(invokemethod008.SGNL_ABORT)) {
+ log.display("invoked_method:: aborted.");
+ }
+ } catch(Exception e) {
+ log.display("unexpected exception " + e);
+ }
+ return Consts.TEST_FAILED;
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009.java
new file mode 100644
index 00000000000..802bf810a3e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009.java
@@ -0,0 +1,303 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.invokeMethod;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+import java.io.*;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+/**
+ * The test checks that the JDI method
+ * com.sun.jdi.ClassType.invokeMethod()
+ * properly throws ClassNotLoadedException - if any argument type
+ * has not yet been loaded through the appropriate class loader.
+ *
+ * The test works as follows. Debugger part of the test invokes
+ * debuggee methods dummyMeth, finDummyMeth with arguments of
+ * non-loaded reference types DummyType, FinDummyType.
+ * The test makes sure that class has not been loaded by the debuggee
+ * VM through the JDI method
+ *
+ * The test works as follows. Debugger part of the test attempts
+ * to invoke several debuggee methods using main debuggee thread
+ * invokemethod010tThr has been suspended by the JDI method
+ * ThreadReference.suspend() instead of by an event.
+ */
+public class invokemethod010 {
+ static final String DEBUGGEE_CLASS =
+ "nsk.jdi.ClassType.invokeMethod.invokemethod010t";
+
+ // name of debuggee main thread
+ static final String DEBUGGEE_THRNAME = "invokemethod010tThr";
+
+ // tested debuggee methods and type reference numbers
+ static final int METH_NUM = 10;
+ static final String DEBUGGEE_METHODS[] = {
+ "byteMeth",
+ "shortMeth",
+ "intMeth",
+ "longMeth",
+ "floatMeth",
+ "doubleMeth",
+ "charMeth",
+ "booleanMeth",
+ "strMeth",
+ "voidMeth"
+ };
+
+ static final String COMMAND_READY = "ready";
+ static final String COMMAND_QUIT = "quit";
+
+ static final int ATTEMPTS = 5;
+ static final int TIMEOUT_DELTA = 1000; // in milliseconds
+
+ private ArgumentHandler argHandler;
+ private Log log;
+ private IOPipe pipe;
+ private Debugee debuggee;
+ private VirtualMachine vm;
+ private ThreadReference thrRef = null;
+ private int tot_res = Consts.TEST_PASSED;
+
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+ return new invokemethod010().runIt(argv, out);
+ }
+
+ private int runIt(String args[], PrintStream out) {
+ argHandler = new ArgumentHandler(args);
+ log = new Log(out, argHandler);
+ Binder binder = new Binder(argHandler, log);
+ String cmd;
+ int num = 0;
+
+ debuggee = binder.bindToDebugee(DEBUGGEE_CLASS);
+ pipe = debuggee.createIOPipe();
+ vm = debuggee.VM();
+ debuggee.redirectStderr(log, "invokemethod010t.err> ");
+ debuggee.resume();
+ cmd = pipe.readln();
+ if (!cmd.equals(COMMAND_READY)) {
+ log.complain("TEST BUG: unknown debuggee command: " + cmd);
+ tot_res = Consts.TEST_FAILED;
+ return quitDebuggee();
+ }
+
+ if ((thrRef =
+ debuggee.threadByName(DEBUGGEE_THRNAME)) == null) {
+ log.complain("TEST FAILURE: method Debugee.threadByName() returned null for debuggee thread "
+ + DEBUGGEE_THRNAME);
+ tot_res = Consts.TEST_FAILED;
+ return quitDebuggee();
+ }
+ thrRef.suspend();
+ while(!thrRef.isSuspended()) {
+ num++;
+ if (num > ATTEMPTS) {
+ log.complain("TEST FAILED: unable to suspend debuggee thread");
+ tot_res = Consts.TEST_FAILED;
+ return quitDebuggee();
+ }
+ log.display("Waiting for debuggee thread suspension ...");
+ try {
+ Thread.currentThread().sleep(TIMEOUT_DELTA);
+ } catch(InterruptedException ie) {
+ ie.printStackTrace();
+ log.complain("TEST FAILED: caught: " + ie);
+ tot_res = Consts.TEST_FAILED;
+ return quitDebuggee();
+ }
+ }
+
+ try {
+ // debuggee main class
+ ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS);
+ ClassType clsType = (ClassType) rType;
+
+ for (int i=0; i
+ *
+ * A debuggee part of the test starts several threads. Then debugger
+ * calls the JDI method without and with the flag INVOKE_SINGLE_THREADED
+ * sequentially. During the invocations and after them the threads state
+ * is expected to be as described above.
+ */
+public class invokemethod011 {
+ static final String DEBUGGEE_CLASS =
+ "nsk.jdi.ClassType.invokeMethod.invokemethod011t";
+
+ // debuggee source line where it should be stopped
+ static final int DEBUGGEE_STOPATLINE = 66;
+
+ // debuggee thread names to be check
+ static final int THRDS_NUM = 12;
+ static final String DEBUGGEE_THRNAMES[] = {
+ "invokemethod011tMainThr", "invokemethod011tThr1", "invokemethod011tThr2",
+ "invokemethod011tThr3", "invokemethod011tThr4", "invokemethod011tThr5",
+ "invokemethod011tThr6", "invokemethod011tThr7", "invokemethod011tThr8",
+ "invokemethod011tThr9", "invokemethod011tThr10", "invokemethod011tThr11"
+ };
+
+ // tested debuggee method
+ static final String DEBUGGEE_METHOD =
+ "dummyMeth";
+
+ // debuggee fields used to operate on an invoked method
+ static final String DEBUGGEE_FIELDS[] = {
+ "doExit", "isInvoked"
+ };
+
+ static final String COMMAND_READY = "ready";
+ static final String COMMAND_GO = "go";
+ static final String COMMAND_QUIT = "quit";
+
+ static final int ATTEMPTS = 10;
+ static final int DELAY = 1000; // in milliseconds
+
+ private ArgumentHandler argHandler;
+ private Log log;
+ private IOPipe pipe;
+ private Debugee debuggee;
+ private VirtualMachine vm;
+ private volatile int tot_res = Consts.TEST_PASSED;
+ private BreakpointRequest BPreq;
+ private volatile boolean gotEvent = false;
+
+ public static void main (String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+ return new invokemethod011().runIt(argv, out);
+ }
+
+ private int runIt(String args[], PrintStream out) {
+ argHandler = new ArgumentHandler(args);
+ log = new Log(out, argHandler);
+ Binder binder = new Binder(argHandler, log);
+ String cmd;
+ int num = 0;
+
+ debuggee = binder.bindToDebugee(DEBUGGEE_CLASS);
+ pipe = debuggee.createIOPipe();
+ vm = debuggee.VM();
+ debuggee.redirectStderr(log, "invokemethod011t.err> ");
+ debuggee.resume();
+ cmd = pipe.readln();
+ if (!cmd.equals(COMMAND_READY)) {
+ log.complain("TEST BUG: unknown debuggee command: " + cmd);
+ tot_res = Consts.TEST_FAILED;
+ return quitDebuggee();
+ }
+
+ ThreadReference thrRef[] = new ThreadReference[THRDS_NUM];
+ for (int i=0; i
+ *
+ * A debuggee part of the test starts several threads. The debugger
+ * calls the JDI method with the flag ClassType.INVOKE_SINGLE_THREADED.
+ * Then, during the invocation the debugger resumes some threads.
+ * Upon completing the invocation, these resumed threads are checked
+ * to be not suspended again.
+ */
+public class invokemethod012 {
+ static final String DEBUGGEE_CLASS =
+ "nsk.jdi.ClassType.invokeMethod.invokemethod012t";
+
+ // debuggee source line where it should be stopped
+ static final int DEBUGGEE_STOPATLINE = 68;
+
+ // debuggee fields used to operate on an invoked method
+ static final String DEBUGGEE_FIELDS[] = {
+ "doExit", "isInvoked"
+ };
+
+ // debuggee threads to be check
+ static final int THRDS_NUM = 12;
+ static final String DEBUGGEE_THRDS[][] = {
+ {"invokemethod012tMainThr", "no"},
+ {"invokemethod012tThr1", "no"},
+ {"invokemethod012tThr2", "resume"},
+ {"invokemethod012tThr3", "resume"},
+ {"invokemethod012tThr4", "no"},
+ {"invokemethod012tThr5", "no"},
+ {"invokemethod012tThr6", "no"},
+ {"invokemethod012tThr7", "no"},
+ {"invokemethod012tThr8", "resume"},
+ {"invokemethod012tThr9", "no"},
+ {"invokemethod012tThr10", "no"},
+ {"invokemethod012tThr11", "resume"}
+ };
+
+ // debuggee method to be invoke
+ static final String DEBUGGEE_METHOD =
+ "dummyMeth";
+
+ static final int ATTEMPTS = 10;
+ static final int DELAY = 500; // in milliseconds
+
+ static final String COMMAND_READY = "ready";
+ static final String COMMAND_GO = "go";
+ static final String COMMAND_QUIT = "quit";
+
+ private ArgumentHandler argHandler;
+ private Log log;
+ private IOPipe pipe;
+ private Debugee debuggee;
+ private VirtualMachine vm;
+ private volatile int tot_res = Consts.TEST_PASSED;
+ private BreakpointRequest BPreq;
+ private volatile boolean gotEvent = false;
+
+ public static void main (String argv[]) {
+ System.exit(run(argv,System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+ return new invokemethod012().runIt(argv, out);
+ }
+
+ private int runIt(String args[], PrintStream out) {
+ argHandler = new ArgumentHandler(args);
+ log = new Log(out, argHandler);
+ Binder binder = new Binder(argHandler, log);
+
+ debuggee = binder.bindToDebugee(DEBUGGEE_CLASS);
+ pipe = debuggee.createIOPipe();
+ vm = debuggee.VM();
+ debuggee.redirectStderr(log, "invokemethod012t.err> ");
+ debuggee.resume();
+ String cmd = pipe.readln();
+ if (!cmd.equals(COMMAND_READY)) {
+ log.complain("TEST BUG: unknown debuggee command: " + cmd);
+ tot_res = Consts.TEST_FAILED;
+ return quitDebuggee();
+ }
+
+ ThreadReference thrRef[] = new ThreadReference[THRDS_NUM];
+ for (int i=0; i
+ *
+ * The following assertions are verified:
+ *
+ *
+ * A debuggee part of the test starts several threads. The debugger
+ * suspends all threads by a breakpoint event and then, some
+ * of them one more time. After that, it calls the JDI method. The
+ * threads are checked to be resumed or remain suspended during the
+ * invocation (depending on the suspend count), and, upon completing
+ * the invocation, to be suspended again.
+ */
+public class invokemethod013 {
+ static final String DEBUGGEE_CLASS =
+ "nsk.jdi.ClassType.invokeMethod.invokemethod013t";
+
+ // debuggee source line where it should be stopped
+ static final int DEBUGGEE_STOPATLINE = 68;
+
+ // debuggee fields used to operate on invoked method
+ static final String DEBUGGEE_FIELDS[] = {
+ "doExit", "isInvoked"
+ };
+
+ // debuggee threads to be check and their suspend count
+ static final int THRDS_NUM = 12;
+ static final String DEBUGGEE_THRDS[][] = {
+ {"invokemethod013tThr", "single-suspension"},
+ {"invokemethod013tThr1", "single-suspension"},
+ {"invokemethod013tThr2", "single-suspension"},
+ {"invokemethod013tThr3", "single-suspension"},
+ {"invokemethod013tThr4", "double-suspension"},
+ {"invokemethod013tThr5", "single-suspension"},
+ {"invokemethod013tThr6", "single-suspension"},
+ {"invokemethod013tThr7", "single-suspension"},
+ {"invokemethod013tThr8", "double-suspension"},
+ {"invokemethod013tThr9", "double-suspension"},
+ {"invokemethod013tThr10", "single-suspension"},
+ {"invokemethod013tThr11", "double-suspension"}
+ };
+
+ // debuggee method to be invoke
+ static final String DEBUGGEE_METHOD =
+ "dummyMeth";
+
+ static final int ATTEMPTS = 10;
+ static final int DELAY = 400; // in milliseconds
+
+ static final String COMMAND_READY = "ready";
+ static final String COMMAND_GO = "go";
+ static final String COMMAND_QUIT = "quit";
+
+ private ArgumentHandler argHandler;
+ private Log log;
+ private IOPipe pipe;
+ private Debugee debuggee;
+ private VirtualMachine vm;
+ private volatile int tot_res = Consts.TEST_PASSED;
+ private BreakpointRequest BPreq;
+ private volatile boolean gotEvent = false;
+
+ public static void main (String argv[]) {
+ System.exit(run(argv,System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+ return new invokemethod013().runIt(argv, out);
+ }
+
+ private int runIt(String args[], PrintStream out) {
+ argHandler = new ArgumentHandler(args);
+ log = new Log(out, argHandler);
+ Binder binder = new Binder(argHandler, log);
+
+ debuggee = binder.bindToDebugee(DEBUGGEE_CLASS);
+ pipe = debuggee.createIOPipe();
+ vm = debuggee.VM();
+ debuggee.redirectStderr(log, "invokemethod013t.err> ");
+ debuggee.resume();
+ String cmd = pipe.readln();
+ if (!cmd.equals(COMMAND_READY)) {
+ log.complain("TEST BUG: unknown debuggee command: " + cmd);
+ tot_res = Consts.TEST_FAILED;
+ return quitDebuggee();
+ }
+
+ ThreadReference thrRef[] = new ThreadReference[THRDS_NUM];
+ for (int i=0; iVirtualMachine.classesByName()
+ * which should return list of loaded classes only.
+ */
+public class invokemethod009 {
+ static final String DEBUGGEE_CLASS =
+ "nsk.jdi.ClassType.invokeMethod.invokemethod009t";
+
+ // name of debuggee main thread
+ static final String DEBUGGEE_THRNAME = "invokemethod009tThr";
+
+ // debuggee source line where it should be stopped
+ static final int DEBUGGEE_STOPATLINE = 57;
+
+ // tested debuggee methods, fields and reference types
+ static final int METH_NUM = 2;
+ static final String DEBUGGEE_METHODS[][] = {
+ {"dummyMeth", "nsk.jdi.ClassType.invokeMethod.invokemethod009tDummyType",
+ "Lnsk/jdi/ClassType/invokeMethod/invokemethod009tDummyType;" },
+ {"finDummyMeth", "nsk.jdi.ClassType.invokeMethod.invokemethod009tFinDummyType",
+ "Lnsk/jdi/ClassType/invokeMethod/invokemethod009tFinDummyType;"}
+ };
+
+ static final int TIMEOUT_DELTA = 1000; // in milliseconds
+
+ static final String COMMAND_READY = "ready";
+ static final String COMMAND_GO = "go";
+ static final String COMMAND_QUIT = "quit";
+
+ private ArgumentHandler argHandler;
+ private Log log;
+ private IOPipe pipe;
+ private Debugee debuggee;
+ private VirtualMachine vm;
+ private ThreadReference thrRef = null;
+ private BreakpointRequest BPreq;
+ private volatile int tot_res = Consts.TEST_PASSED;
+ private volatile boolean gotEvent = false;
+
+ public static void main (String argv[]) {
+ System.exit(run(argv,System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+ return new invokemethod009().runIt(argv, out);
+ }
+
+ private int runIt(String args[], PrintStream out) {
+ argHandler = new ArgumentHandler(args);
+ log = new Log(out, argHandler);
+ Binder binder = new Binder(argHandler, log);
+ String cmd;
+ int num = 0;
+
+ debuggee = binder.bindToDebugee(DEBUGGEE_CLASS);
+ pipe = debuggee.createIOPipe();
+ vm = debuggee.VM();
+ debuggee.redirectStderr(log, "invokemethod009t.err> ");
+ debuggee.resume();
+ cmd = pipe.readln();
+ if (!cmd.equals(COMMAND_READY)) {
+ log.complain("TEST BUG: unknown debuggee command: " + cmd);
+ tot_res = Consts.TEST_FAILED;
+ return quitDebuggee();
+ }
+
+ if ((thrRef =
+ debuggee.threadByName(DEBUGGEE_THRNAME)) == null) {
+ log.complain("TEST FAILURE: Method Debugee.threadByName() returned null for debuggee thread "
+ + DEBUGGEE_THRNAME);
+ tot_res = Consts.TEST_FAILED;
+ return quitDebuggee();
+ }
+ // debuggee main class
+ ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS);
+
+// Check the tested assersion
+ try {
+ suspendAtBP(rType, DEBUGGEE_STOPATLINE);
+ ClassType clsType = (ClassType) rType;
+
+ for (int i=0; icom.sun.jdi.ClassType.invokeMethod()
+ * properly throws IncompatibleThreadStateException - if the
+ * specified thread has not been suspended by an event.
+ * com.sun.jdi.ClassType.invokeMethod().
+ * The following assertions are verified:
+ * com.sun.jdi.ClassType.invokeMethod().
+ * The following assertions are verified:
+ *
+ * com.sun.jdi.ClassType.invokeMethod().com.sun.jdi.ClassType.invokeMethod()
+ * properly throws IllegalArgumentException when
+ * debugger part of the test attempts to invoke several
+ * debuggee methods:
+ *
+ * ClassType.
+ *
+ * The test checks up that results of the method
+ * com.sun.jdi.ClassType.newInstance()
+ * complies with its specification.
+ * The case for testing includes invoking the method to create
+ * new instance of the class TestClass
+ * which is global to a class implementing debuggee's thread
+ * in which instance creation is performed.
+ * No exception is expected to be thrown in response to call
+ * to the method.
+ *
+ * The test works as follows.
+ * A debugger launchs a debuggee which creates new thread, thread2.
+ * The tested class TestClass is specified outside of the class
+ * Threadnewinstance002a extends Thread
+ * After getting thread2 running but locked at a monitor
+ * the debugger informs the debugger of the thread2 creation
+ * and waits for an instruction from it.
+ * Upon receiving the message from the debuggee, the debugger
+ * sets up a breakpoint for the thread2 and instructs the
+ * debuggee to unlock the thread2 and after getting it suspended
+ * at the breakpoint, prepares arguments and invokes the method.
+ * After the method completes, the debugger checks up on
+ * a returned ObjectReference value;
+ * the following is expected to be true:
+ * objRef.referenceType().equals(classType)
+ * where
+ * ObjectReference objRef - is returned value
+ * ClassType classType - is a mirror of the tested class.
+ */
+
+public class newinstance001 {
+
+ //----------------------------------------------------- templete section
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ //----------------------------------------------------- templete parameters
+ static final String
+ sHeader1 = "\n==> nsk/jdi/ClassType/newInstance/newinstance001 ",
+ sHeader2 = "--> debugger: ",
+ sHeader3 = "##> debugger: ";
+
+ //----------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+ int result = run(argv, System.out);
+ System.exit(result + PASS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ return new newinstance001().runThis(argv, out);
+ }
+
+ //-------------------------------------------------- log procedures
+
+ private static Log logHandler;
+
+ private static void log1(String message) {
+ logHandler.display(sHeader1 + message);
+ }
+ private static void log2(String message) {
+ logHandler.display(sHeader2 + message);
+ }
+ private static void log3(String message) {
+ logHandler.complain(sHeader3 + message);
+ }
+
+ // ************************************************ test parameters
+
+ private String debuggeeName =
+ "nsk.jdi.ClassType.newInstance.newinstance001a";
+
+ private String testedClassName =
+ "nsk.jdi.ClassType.newInstance.TestClass";
+
+ private String threadName = "testedThread";
+
+ private String threadClassName =
+ "nsk.jdi.ClassType.newInstance.Threadnewinstance001a";
+
+ //String mName = "nsk.jdi.ClassType.newInstance";
+
+ //====================================================== test program
+ //------------------------------------------------------ common section
+
+ static ArgumentHandler argsHandler;
+
+ static int waitTime;
+
+ static VirtualMachine vm = null;
+ static EventRequestManager eventRManager = null;
+ static EventQueue eventQueue = null;
+ static EventSet eventSet = null;
+
+ ReferenceType testedClass = null;
+
+ ReferenceType threadClass = null;
+
+ ThreadReference thread2 = null;
+ ThreadReference mainThread = null;
+
+ static int testExitCode = PASSED;
+
+ static final int returnCode0 = 0;
+ static final int returnCode1 = 1;
+ static final int returnCode2 = 2;
+ static final int returnCode3 = 3;
+ static final int returnCode4 = 4;
+
+ //------------------------------------------------------ methods
+
+ private int runThis (String argv[], PrintStream out) {
+
+ Debugee debuggee;
+
+ argsHandler = new ArgumentHandler(argv);
+ logHandler = new Log(out, argsHandler);
+ Binder binder = new Binder(argsHandler, logHandler);
+
+ if (argsHandler.verbose()) {
+ debuggee = binder.bindToDebugee(debuggeeName + " -vbs");
+ } else {
+ debuggee = binder.bindToDebugee(debuggeeName);
+ }
+
+ waitTime = argsHandler.getWaitTime();
+
+
+ IOPipe pipe = new IOPipe(debuggee);
+
+ debuggee.redirectStderr(out);
+ log2("issuspended002a debuggee launched");
+ debuggee.resume();
+
+ String line = pipe.readln();
+ if ((line == null) || !line.equals("ready")) {
+ log3("signal received is not 'ready' but: " + line);
+ return FAILED;
+ } else {
+ log2("'ready' recieved");
+ }
+
+ vm = debuggee.VM();
+
+ //------------------------------------------------------ testing section
+ log1(" TESTING BEGINS");
+
+ for (int i = 0; ; i++) {
+
+ pipe.println("newcheck");
+ line = pipe.readln();
+
+ if (line.equals("checkend")) {
+ log2(" : returned string is 'checkend'");
+ break ;
+ } else if (!line.equals("checkready")) {
+ log3("ERROR: returned string is not 'checkready'");
+ testExitCode = FAILED;
+ break ;
+ }
+
+ log1("new checkready: #" + i);
+
+ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
+
+ int expresult = returnCode0;
+
+
+ eventRManager = vm.eventRequestManager();
+ eventQueue = vm.eventQueue();
+
+ String breakpointMethod1 = "runt1";
+
+ String bpLine1 = "breakpointLineNumber1";
+
+ List allThreads = null;
+ ListIterator listIterator = null;
+ List classes = null;
+
+ BreakpointRequest breakpRequest1 = null;
+
+ ClassType classType = null;
+
+ label0: {
+
+ log2("getting ThreadReference object");
+ try {
+ allThreads = vm.allThreads();
+ classes = vm.classesByName(threadClassName);
+ threadClass = (ReferenceType) classes.get(0);
+ } catch ( Exception e) {
+ log3("ERROR: Exception at very beginning !? : " + e);
+ expresult = returnCode1;
+ break label0;
+ }
+
+
+ log2("......getting Thread thread2 - 1-st argument");
+ listIterator = allThreads.listIterator();
+ for (;;) {
+ try {
+ thread2 = (ThreadReference) listIterator.next();
+ if (thread2.name().equals(threadName))
+ break ;
+ } catch ( NoSuchElementException e ) {
+ log3("ERROR: NoSuchElementException for listIterator.next()");
+ log3("ERROR: NO THREAD2 ?????????!!!!!!!");
+ expresult = returnCode1;
+ break label0;
+ }
+ }
+
+ log2("setting up a breakpoint");
+
+ breakpRequest1 = settingBreakpoint(breakpointMethod1, bpLine1, "one");
+ if (breakpRequest1 == null) {
+ expresult = returnCode1;
+ break label0;
+ }
+ }
+
+ label1: {
+
+ if (expresult != returnCode0)
+ break label1;
+
+ log2(" enabling breakpRequest1");
+ breakpRequest1.enable();
+
+ log2(" forcing the main thread to leave synchronized block");
+ pipe.println("continue");
+ line = pipe.readln();
+ if (!line.equals("docontinue")) {
+ log3("ERROR: returned string is not 'docontinue'");
+ expresult = returnCode4;
+ break label1;
+ }
+
+ log2(" getting BreakpointEvent");
+ expresult = breakpoint();
+ if (expresult != returnCode0)
+ break label1;
+ log2(" thread2 is at breakpoint");
+
+
+ log2("......getting ClassType classType - an object to apply newInstance()");
+ classes = vm.classesByName(testedClassName);
+ testedClass = (ReferenceType) classes.get(0);
+ classType = (ClassType) testedClass;
+
+ List invokeMethods = testedClass.methods();
+ ListIterator li = invokeMethods.listIterator();
+
+ Method invokeMethod = null;
+
+ log2("......getting Method invokeMethod - a constructor to invoke; 2-nd argument");
+ try {
+ for (;;) {
+ invokeMethod = (Method) li.next();
+ if (!invokeMethod.isConstructor())
+ continue;
+ if (invokeMethod.arguments().size() == 0)
+ break;
+ }
+ } catch ( AbsentInformationException e1 ) {
+ log2(" AbsentInformationException ");
+ break label1;
+ } catch ( NoSuchElementException e2 ) {
+ log3("ERROR: NoSuchElementException ");
+ expresult = returnCode2;
+ break label1;
+ }
+
+
+ // this is only to get an empty List with JDI methods but not with API List methods
+ log2("......forming an empty List argumentList for 3-d argument");
+ log2(" List argumentList = testedClass.methodsByName('m');");
+ List
+ *
+ * The test checks up that results of the method
+ * com.sun.jdi.ClassType.newInstance()
+ * complies with its specification.
+ * The case for testing includes invoking the method to create
+ * new instance of an inner class of ClassType extending Thread class.
+ * No exception is expected to be thrown in response to call
+ * to the method.
+ *
+ * The test works as follows.
+ * A debugger launchs a debuggee which creates new thread, thread2
+ * a tested class TestClass1 is specified within a class
+ * Threadnewinstance002a extends Thread
+ * After getting thread2 running but locked at a monitor
+ * the debugger informs the debugger of the thread2 creation
+ * and waits for an instruction from it.
+ * Upon receiving the message from the debuggee, the debugger
+ * sets up a breakpoint for the thread2 and instructs the
+ * debuggee to unlock the thread2 and after getting it suspended
+ * at the breakpoint, prepares arguments and invokes the method.
+ * After the method completes, the debugger checks up on
+ * a returned ObjectReference value; the following is expected
+ * to be true:
+ * objRef.referenceType().equals(classType)
+ * where
+ * ObjectReference objRef - is returned value
+ * ClassType classType - is a mirror of the tested class.
+ */
+
+public class newinstance002 {
+
+ //----------------------------------------------------- templete section
+ static final int PASSED = 0;
+ static final int FAILED = 2;
+ static final int PASS_BASE = 95;
+
+ //----------------------------------------------------- templete parameters
+ static final String
+ sHeader1 = "\n==> nsk/jdi/ClassType/newInstance/newinstance002 ",
+ sHeader2 = "--> debugger: ",
+ sHeader3 = "##> debugger: ";
+
+ //----------------------------------------------------- main method
+
+ public static void main (String argv[]) {
+ int result = run(argv, System.out);
+ System.exit(result + PASS_BASE);
+ }
+
+ public static int run (String argv[], PrintStream out) {
+ return new newinstance002().runThis(argv, out);
+ }
+
+ //-------------------------------------------------- log procedures
+
+ private static Log logHandler;
+
+ private static void log1(String message) {
+ logHandler.display(sHeader1 + message);
+ }
+ private static void log2(String message) {
+ logHandler.display(sHeader2 + message);
+ }
+ private static void log3(String message) {
+ logHandler.complain(sHeader3 + message);
+ }
+
+ // ************************************************ test parameters
+
+ private String debuggeeName =
+ "nsk.jdi.ClassType.newInstance.newinstance002a";
+
+ private String testedClassName =
+ "nsk.jdi.ClassType.newInstance.Threadnewinstance002a$TestClass1";
+
+ private String threadName = "testedThread";
+
+ private String threadClassName =
+ "nsk.jdi.ClassType.newInstance.Threadnewinstance002a";
+
+ //String mName = "nsk.jdi.ClassType.newInstance";
+
+ //====================================================== test program
+ //------------------------------------------------------ common section
+
+ static ArgumentHandler argsHandler;
+
+ static int waitTime;
+
+ static VirtualMachine vm = null;
+ static EventRequestManager eventRManager = null;
+ static EventQueue eventQueue = null;
+ static EventSet eventSet = null;
+
+ ReferenceType testedClass = null;
+
+ ReferenceType threadClass = null;
+ ThreadReference thread2 = null;
+ ThreadReference mainThread = null;
+
+ static int testExitCode = PASSED;
+
+ static final int returnCode0 = 0;
+ static final int returnCode1 = 1;
+ static final int returnCode2 = 2;
+ static final int returnCode3 = 3;
+ static final int returnCode4 = 4;
+
+ //------------------------------------------------------ methods
+
+ private int runThis (String argv[], PrintStream out) {
+
+ Debugee debuggee;
+
+ argsHandler = new ArgumentHandler(argv);
+ logHandler = new Log(out, argsHandler);
+ Binder binder = new Binder(argsHandler, logHandler);
+
+ if (argsHandler.verbose()) {
+ debuggee = binder.bindToDebugee(debuggeeName + " -vbs");
+ } else {
+ debuggee = binder.bindToDebugee(debuggeeName);
+ }
+
+ waitTime = argsHandler.getWaitTime();
+
+
+ IOPipe pipe = new IOPipe(debuggee);
+
+ debuggee.redirectStderr(out);
+ log2("issuspended002a debuggee launched");
+ debuggee.resume();
+
+ String line = pipe.readln();
+ if ((line == null) || !line.equals("ready")) {
+ log3("signal received is not 'ready' but: " + line);
+ return FAILED;
+ } else {
+ log2("'ready' recieved");
+ }
+
+ vm = debuggee.VM();
+
+ //------------------------------------------------------ testing section
+ log1(" TESTING BEGINS");
+
+ for (int i = 0; ; i++) {
+
+ pipe.println("newcheck");
+ line = pipe.readln();
+
+ if (line.equals("checkend")) {
+ log2(" : returned string is 'checkend'");
+ break ;
+ } else if (!line.equals("checkready")) {
+ log3("ERROR: returned string is not 'checkready'");
+ testExitCode = FAILED;
+ break ;
+ }
+
+ log1("new checkready: #" + i);
+
+ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
+
+ int expresult = returnCode0;
+
+
+ eventRManager = vm.eventRequestManager();
+ eventQueue = vm.eventQueue();
+
+ String breakpointMethod1 = "runt1";
+
+ String bpLine1 = "breakpointLineNumber1";
+
+ List allThreads = null;
+ ListIterator listIterator = null;
+ List classes = null;
+
+ BreakpointRequest breakpRequest1 = null;
+
+ ClassType classType = null;
+
+ label0: {
+
+ log2("getting ThreadReference object");
+ try {
+ allThreads = vm.allThreads();
+ classes = vm.classesByName(threadClassName);
+ threadClass = (ReferenceType) classes.get(0);
+ } catch ( Exception e) {
+ log3("ERROR: Exception at very beginning !? : " + e);
+ expresult = returnCode1;
+ break label0;
+ }
+
+
+ listIterator = allThreads.listIterator();
+ for (;;) {
+ try {
+ thread2 = (ThreadReference) listIterator.next();
+ if (thread2.name().equals(threadName))
+ break ;
+ } catch ( NoSuchElementException e ) {
+ log3("ERROR: NoSuchElementException for listIterator.next()");
+ log3("ERROR: NO THREAD2 ?????????!!!!!!!");
+ expresult = returnCode1;
+ break label0;
+ }
+ }
+
+ log2("setting up a breakpoint");
+
+ breakpRequest1 = settingBreakpoint(breakpointMethod1, bpLine1, "one");
+ if (breakpRequest1 == null) {
+ expresult = returnCode1;
+ break label0;
+ }
+ }
+
+ label1: {
+
+ if (expresult != returnCode0)
+ break label1;
+
+ log2(" enabling breakpRequest1");
+ breakpRequest1.enable();
+
+ log2(" forcing the main thread to leave synchronized block");
+ pipe.println("continue");
+ line = pipe.readln();
+ if (!line.equals("docontinue")) {
+ log3("ERROR: returned string is not 'docontinue'");
+ expresult = returnCode4;
+ break label1;
+ }
+
+ log2(" getting BreakpointEvent");
+ expresult = breakpoint();
+ if (expresult != returnCode0)
+ break label1;
+ log2(" thread2 is at breakpoint");
+
+
+ log2("......getting ClassType classType - an object to apply newInstance()");
+ classes = vm.classesByName(testedClassName);
+ testedClass = (ReferenceType) classes.get(0);
+ classType = (ClassType) testedClass;
+
+ List invokeMethods = testedClass.methods();
+ ListIterator li = invokeMethods.listIterator();
+
+ Method invokeMethod = null;
+
+ log2("......getting Method invokeMethod - a constructor to invoke; 2-nd argument");
+ try {
+ for (;;) {
+ invokeMethod = (Method) li.next();
+ if (!invokeMethod.isConstructor())
+ continue;
+ if (invokeMethod.arguments().size() == 0)
+ break;
+ }
+ } catch ( AbsentInformationException e1 ) {
+ log2(" AbsentInformationException ");
+ break label1;
+ } catch ( NoSuchElementException e2 ) {
+ log3("ERROR: NoSuchElementException ");
+ expresult = returnCode2;
+ break label1;
+ }
+
+
+ ObjectReference objRef = null;
+
+ log2("......ObjectReference objRef = classType.newInstance(thread2, invokeMethod, Arrays.asList(thread2), 0);");
+ log2(" No Exception is expected");
+ try {
+ objRef = classType.newInstance(thread2,
+ invokeMethod, Arrays.asList(thread2), 0);
+ if (objRef == null)
+ log2(" objRe == null");
+
+
+ log2(" ReferenceType refType = objRef.referenceType();");
+ ReferenceType refType = objRef.referenceType();
+
+ log2(" ClassType cType = (ClassType) refType;");
+ ClassType cType = (ClassType) refType;
+
+ log2("......checking up on: cType.equals(classType); ");
+ if (!cType.equals(classType)) {
+ log3("ERROR: !cType.equals(classType)");
+ expresult = returnCode1;
+ }
+
+ } catch ( Exception e ) {
+ log3("ERROR: Exception for classType.newInstance() :" + e);
+ expresult = returnCode1;
+ }
+
+ }
+ vm.resume(); // for case if thread2 was not resumed because of error in a check
+
+ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ log2(" the end of testing");
+ if (expresult != returnCode0)
+ testExitCode = FAILED;
+ }
+ log1(" TESTING ENDS");
+
+ //-------------------------------------------------- test summary section
+ //------------------------------------------------- standard end section
+
+ pipe.println("quit");
+ log2("waiting for the debuggee to finish ...");
+ debuggee.waitFor();
+
+ int status = debuggee.getStatus();
+ if (status != PASSED + PASS_BASE) {
+ log3("debuggee returned UNEXPECTED exit status: " +
+ status + " != PASS_BASE");
+ testExitCode = FAILED;
+ } else {
+ log2("debuggee returned expected exit status: " +
+ status + " == PASS_BASE");
+ }
+
+ if (testExitCode != PASSED) {
+ System.out.println("TEST FAILED");
+ }
+ return testExitCode;
+ }
+
+
+ /*
+ * private BreakpointRequest settingBreakpoint(String, String, String)
+ *
+ * It sets up a breakpoint within a given method at given line number
+ * for the thread2 only.
+ * Third parameter is required for any case in future debugging, as if.
+ *
+ * Return codes:
+ * = BreakpointRequest object in case of success
+ * = null in case of an Exception thrown within the method
+ */
+
+ private BreakpointRequest settingBreakpoint ( String methodName,
+ String bpLine,
+ String property) {
+
+ log2("setting up a breakpoint: method: '" + methodName + "' line: " + bpLine );
+
+ List alllineLocations = null;
+ Location lineLocation = null;
+ BreakpointRequest breakpRequest = null;
+
+ try {
+// Method method = (Method) testedclass.methodsByName(methodName).get(0);
+ Method method = (Method) threadClass.methodsByName(methodName).get(0);
+
+ alllineLocations = method.allLineLocations();
+
+ int n =
+// ( (IntegerValue) testedclass.getValue(testedclass.fieldByName(bpLine) ) ).value();
+ ( (IntegerValue) threadClass.getValue(threadClass.fieldByName(bpLine) ) ).value();
+ if (n > alllineLocations.size()) {
+ log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines");
+ } else {
+ lineLocation = (Location) alllineLocations.get(n);
+ try {
+ breakpRequest = eventRManager.createBreakpointRequest(lineLocation);
+ breakpRequest.putProperty("number", property);
+ breakpRequest.addThreadFilter(thread2);
+ breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD);
+ } catch ( Exception e1 ) {
+ log3("ERROR: inner Exception within settingBreakpoint() : " + e1);
+ breakpRequest = null;
+ }
+ }
+ } catch ( Exception e2 ) {
+ log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2);
+ breakpRequest = null;
+ }
+
+ if (breakpRequest == null)
+ log2(" A BREAKPOINT HAS NOT BEEN SET UP");
+ else
+ log2(" a breakpoint has been set up");
+
+ return breakpRequest;
+ }
+
+
+ /*
+ * private int breakpoint ()
+ *
+ * It removes events from EventQueue until gets first BreakpointEvent.
+ * To get next EventSet value, it uses the method
+ * EventQueue.remove(int timeout)
+ * The timeout argument passed to the method, is "waitTime*60000".
+ * Note: the value of waitTime is set up with
+ * the method ArgumentHandler.getWaitTime() at the beginning of the test.
+ *
+ * Return codes:
+ * = returnCode0 - success;
+ * = returnCode2 - Exception when "eventSet = eventQueue.remove()" is executed
+ * = returnCode3 - default case when loop of processing an event, that is,
+ * an unspecified event was taken from the EventQueue
+ */
+
+ private int breakpoint () {
+
+ int returnCode = returnCode0;
+
+ log2(" waiting for BreakpointEvent");
+
+ labelBP:
+ for (;;) {
+
+ log2(" new: eventSet = eventQueue.remove();");
+ try {
+ eventSet = eventQueue.remove(waitTime*60000);
+ if (eventSet == null) {
+ log3("ERROR: timeout for waiting for a BreakpintEvent");
+ returnCode = returnCode3;
+ break labelBP;
+ }
+ } catch ( Exception e ) {
+ log3("ERROR: Exception for eventSet = eventQueue.remove(); : " + e);
+ returnCode = 1;
+ break labelBP;
+ }
+
+ if (eventSet != null) {
+
+ log2(" : eventSet != null; size == " + eventSet.size());
+
+ EventIterator eIter = eventSet.eventIterator();
+ Event ev = null;
+
+ for (; eIter.hasNext(); ) {
+
+ if (returnCode != returnCode0)
+ break;
+
+ ev = eIter.nextEvent();
+
+ ll: for (int ifor =0; ; ifor++) {
+
+ try {
+ switch (ifor) {
+
+ case 0: AccessWatchpointEvent awe = (AccessWatchpointEvent) ev;
+ log2(" AccessWatchpointEvent removed");
+ break ll;
+ case 1: BreakpointEvent be = (BreakpointEvent) ev;
+ log2(" BreakpointEvent removed");
+ break labelBP;
+ case 2: ClassPrepareEvent cpe = (ClassPrepareEvent) ev;
+ log2(" ClassPreparEvent removed");
+ break ll;
+ case 3: ClassUnloadEvent cue = (ClassUnloadEvent) ev;
+ log2(" ClassUnloadEvent removed");
+ break ll;
+ case 4: ExceptionEvent ee = (ExceptionEvent) ev;
+ log2(" ExceptionEvent removed");
+ break ll;
+ case 5: MethodEntryEvent mene = (MethodEntryEvent) ev;
+ log2(" MethodEntryEvent removed");
+ break ll;
+ case 6: MethodExitEvent mexe = (MethodExitEvent) ev;
+ log2(" MethodExiEvent removed");
+ break ll;
+ case 7: ModificationWatchpointEvent mwe = (ModificationWatchpointEvent) ev;
+ log2(" ModificationWatchpointEvent removed");
+ break ll;
+ case 8: StepEvent se = (StepEvent) ev;
+ log2(" StepEvent removed");
+ break ll;
+ case 9: ThreadDeathEvent tde = (ThreadDeathEvent) ev;
+ log2(" ThreadDeathEvent removed");
+ break ll;
+ case 10: ThreadStartEvent tse = (ThreadStartEvent) ev;
+ log2(" ThreadStartEvent removed");
+ break ll;
+ case 11: VMDeathEvent vmde = (VMDeathEvent) ev;
+ log2(" VMDeathEvent removed");
+ break ll;
+ case 12: VMStartEvent vmse = (VMStartEvent) ev;
+ log2(" VMStartEvent removed");
+ break ll;
+ case 13: WatchpointEvent we = (WatchpointEvent) ev;
+ log2(" WatchpointEvent removed");
+ break ll;
+
+ default: log3("ERROR: default case for casting event");
+ returnCode = returnCode3;
+ break ll;
+ } // switch
+ } catch ( ClassCastException e ) {
+ } // try
+ } // ll: for (int ifor =0; ; ifor++)
+ } // for (; ev.hasNext(); )
+ }
+ }
+ if (returnCode == returnCode0)
+ log2(" : eventSet == null: EventQueue is empty");
+
+ return returnCode;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance002/TestDescription.java
new file mode 100644
index 00000000000..947582c18e8
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance002/TestDescription.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2018, 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
+ *
+ * @summary converted from VM Testbase nsk/jdi/ClassType/newInstance/newinstance002.
+ * VM Testbase keywords: [jpda, jdi, quarantine]
+ * VM Testbase comments: JDK-4462897
+ * VM Testbase readme:
+ * DESCRIPTION:
+ * The test for the implementation of an object of the type
+ * ClassType.
+ * The test checks up that a result of the method
+ * com.sun.jdi.ClassType.newInstance()
+ * complies with its spec:
+ * public ObjectReference newInstance(ThreadReference thread,
+ * Method method,
+ * List arguments,
+ * int options)
+ * throws InvalidTypeException,
+ * ClassNotLoadedException,
+ * IncompatibleThreadStateException,
+ * InvocationException
+ * Constructs a new instance of this type, using the given constructor Method
+ * in the target VM. The specified constructor must be defined in the this class.
+ * Instance creation will occur in the specified thread.
+ * Instance creation can occur only if the specified thread has
+ * been suspended by an event which occurred in that thread.
+ * Instance creation is not supported when the target
+ * VM has been suspended through VirtualMachine.suspend() or
+ * when the specified thread is suspended through ThreadReference.suspend().
+ * The specified constructor is invoked with the arguments in the specified
+ * argument list. The invocation is synchronous; this method does not return
+ * until the constructor returns in the target VM. If the invoked method
+ * throws an exception, this method will throw an InvocationException which
+ * contains a mirror to the exception object thrown.
+ * Object arguments must be assignment compatible with the argument type
+ * (This implies that the argument type must be loaded through the enclosing
+ * class's class loader). Primitive arguments must be either assignment
+ * compatible with the argument type or must be convertible to the argument type
+ * without loss of information.
+ * See JLS section 5.2 for more information on assignment compatibility.
+ * By default, all threads in the target VM are resumed while the method is being
+ * invoked if they were previously suspended by an event or by
+ * VirtualMachine.suspend() or ThreadReference.suspend().
+ * This is done to prevent the deadlocks that will occur if any of the threads own
+ * monitors that will be needed by the invoked method.
+ * It is possible that breakpoints or other events might occur during
+ * the invocation. Note, however, that this implicit resume acts exactly like
+ * ThreadReference.resume(), so if the thread's suspend count is greater than 1,
+ * it will remain in a suspended state during the invocation.
+ * By default, when the invocation completes,
+ * all threads in the target VM are suspended,
+ * regardless their state before the invocation.
+ * The resumption of other threads during the invocation can be prevented by
+ * specifying the INVOKE_SINGLE_THREADED bit flag in the options argument;
+ * however, there is no protection against or recovery from the deadlocks
+ * described above, so this option should be used with great caution.
+ * Only the specified thread will be resumed (as described for all threads above).
+ * Upon completion of a single threaded invoke, the invoking thread will be
+ * suspended once again. Note that any threads started during the single threaded
+ * invocation will not be suspended when the invocation completes.
+ * If the target VM is disconnected during the invoke
+ * (for example, through VirtualMachine.dispose())
+ * the method invocation continues.
+ * Parameters:
+ * thread - the thread in which to invoke.
+ * method - the constructor Method to invoke.
+ * arguments - the list of Value arguments bound to the invoked constructor.
+ * Values from the list are assigned to arguments in
+ * the order they appear in the constructor signature.
+ * options - the integer bit flag options.
+ * Returns:
+ * an ObjectReference mirror of the newly created object.
+ * Throws:
+ * IllegalArgumentException -
+ * if the method is not a member of this class, if the size of the
+ * argument list does not match the number of declared arguments for
+ * the constructor, or if the method is not a constructor.
+ * {
+ * 2. IllegalArgumentException is thrown if
+ * - the method is not a member of this class;
+ * - the size of the argument list does not match the number
+ * of declared arguemnts for the constructor, or if the
+ * method is not a constructor.
+ */
+
+public class newinstance003 {
+
+ private final static String prefix = "nsk.jdi.ClassType.newInstance.";
+ private final static String debuggerName = prefix + "newinstance003";
+ private final static String debugeeName = debuggerName + "a";
+
+ public final static String SGNL_READY = "ready";
+ public final static String SGNL_QUIT = "quit";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+
+ private ClassType testedClass;
+ private ClassType class2Check;
+ private ThreadReference thread;
+
+ class TestRuntimeException extends RuntimeException {
+ TestRuntimeException(String msg) {
+ super("TestRuntimeException: " + msg);
+ }
+ }
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ newinstance003 thisTest = new newinstance003();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ thisTest.execTest();
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() {
+
+ debugee.VM().suspend();
+ class2Check = (ClassType )debugee.classByName(prefix
+ + newinstance003a.class2Check);
+ testedClass = (ClassType )debugee.classByName(debugeeName);
+
+ BreakpointRequest brkp = debugee.makeBreakpoint(testedClass,
+ newinstance003a.brkpMethodName,
+ newinstance003a.brkpLineNumber);
+ brkp.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
+ brkp.enable();
+ debugee.resume();
+
+ debugee.sendSignal("");
+ Event event = null;
+
+ // waiting the breakpoint event
+ try {
+ event = debugee.waitingEvent(brkp, waitTime);
+ } catch (InterruptedException e) {
+ throw new TestRuntimeException("unexpected InterruptedException");
+ }
+ if (!(event instanceof BreakpointEvent )) {
+ debugee.resume();
+ throw new TestRuntimeException("BreakpointEvent didn't arrive");
+ }
+
+ BreakpointEvent brkpEvent = (BreakpointEvent )event;
+
+ thread = brkpEvent.thread();
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ ObjectReference obj = null;
+ Value retValue, value = null,
+ expectedValue = debugee.VM().mirrorOf(6L);
+ Listnewinstance003a is deugee's part of the newinstance003.
+ */
+public class newinstance003a {
+
+ public final static String anotherClassName = "newinstance003b";
+ public final static String class2Check = "newinstance003Child";
+ public final static String method = "insteadOfConstructor";
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 49;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ Log log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ newinstance003Child child = new newinstance003Child(1);
+ pipe.println(newinstance003.SGNL_READY);
+ String instr = pipe.readln();
+ log.display("breakpoint line"); // brkpLineNumber
+ instr = pipe.readln();
+ if (instr.equals(newinstance003.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+
+ }
+
+ protected static long sum;
+ newinstance003a(int one) {
+ sum = one;
+ }
+}
+
+class newinstance003Child extends newinstance003a {
+ newinstance003Child(int one) {
+ super(one);
+ }
+
+ public static void insteadOfConstructor() {
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance004.java
new file mode 100644
index 00000000000..76eb4253c02
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance004.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.newInstance;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * Test checks up the following assertion:
+ * If the invoked method throws an exception, this method will throw
+ * an InvocationException which contains a mirror to the exception object thrown.
+ * It is checked for two cases:
+ * 1. when the invoked method throws uncaught NullPointerExection.
+ * For this case, InvocationException is expected, the one
+ * contains a mirror to the NullPointerException object.
+ * 2. when invoked method throws caught exection
+ * For this case, no exceptions are expected
+ */
+
+public class newinstance004 {
+
+ private final static String prefix = "nsk.jdi.ClassType.newInstance.";
+ private final static String debuggerName = prefix + "newinstance004";
+ private final static String debugeeName = debuggerName + "a";
+
+ public final static String SGNL_READY = "ready";
+ public final static String SGNL_QUIT = "quit";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+
+ private ClassType testedClass;
+ private ThreadReference thread;
+
+ class TestRuntimeException extends RuntimeException {
+ TestRuntimeException(String msg) {
+ super("TestRuntimeException: " + msg);
+ }
+ }
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ newinstance004 thisTest = new newinstance004();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ thisTest.execTest();
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() {
+
+ debugee.VM().suspend();
+ testedClass = (ClassType )debugee.classByName(debugeeName);
+
+ BreakpointRequest brkp = debugee.setBreakpoint(testedClass,
+ newinstance004a.brkpMethodName,
+ newinstance004a.brkpLineNumber);
+ debugee.resume();
+
+ debugee.sendSignal("");
+ Event event = null;
+
+ // waiting the breakpoint event
+ try {
+ event = debugee.waitingEvent(brkp, waitTime);
+ } catch (InterruptedException e) {
+ throw new TestRuntimeException("unexpected InterruptedException");
+ }
+ if (!(event instanceof BreakpointEvent )) {
+ debugee.resume();
+ throw new TestRuntimeException("BreakpointEvent didn't arrive");
+ }
+
+ BreakpointEvent brkpEvent = (BreakpointEvent )event;
+
+ thread = brkpEvent.thread();
+
+ ReferenceType exceptionRefType =
+ debugee.classByName(newinstance004a.testException);
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ Value retValue;
+ ObjectReference obj = null;
+ Listnewinstance004a is deugee's part of the newinstance004.
+ */
+public class newinstance004a {
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 48;
+ public final static String testException = "java.lang.NullPointerException";
+
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ Log log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(newinstance004.SGNL_READY);
+ String instr = pipe.readln();
+ log.display("breakpoint line"); // brkpLineNumber
+ instr = pipe.readln();
+ if (instr.equals(newinstance004.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+
+ newinstance004a(boolean caughtException) {
+ Object obj = null;
+ String tmp;
+ if (caughtException) {
+ try {
+ tmp = obj.toString();
+ } catch (NullPointerException e) {
+ }
+ } else {
+ tmp = obj.toString();
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance005.java
new file mode 100644
index 00000000000..e67364e684c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance005.java
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.newInstance;
+
+import nsk.share.*;
+import nsk.share.jdi.*;
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import java.util.*;
+import java.io.*;
+import java.lang.reflect.Array;
+
+/**
+ * Test checks up the following assertion:
+ * Primitive arguments must be either assignment compatible with
+ * the argument type or must be convertible to the argument type
+ * without loss of information.
+ * for every primitive type
+ */
+
+public class newinstance005 extends ValueConversionDebugger {
+
+ private ClassType testedClass;
+ private ThreadReference thread;
+
+ static class TestedConstructorData {
+ String signature;
+ String fieldName;
+ ValueType type;
+
+ TestedConstructorData(String signature, String fieldName, ValueType type) {
+ this.signature = signature;
+ this.fieldName = fieldName;
+ this.type = type;
+ }
+ }
+
+ private static final TestedConstructorData [] testedConstructors = {
+ new TestedConstructorData("(B)V", "byteValue", BYTE),
+ new TestedConstructorData("(C)V", "charValue", CHAR),
+ new TestedConstructorData("(D)V", "doubleValue", DOUBLE),
+ new TestedConstructorData("(F)V", "floatValue", FLOAT),
+ new TestedConstructorData("(I)V", "intValue", INT),
+ new TestedConstructorData("(J)V", "longValue", LONG),
+ new TestedConstructorData("(S)V", "shortValue", SHORT)
+ };
+
+
+ private Field field;
+
+ private static byte [] byteParamValues =
+ {Byte.MIN_VALUE,
+ -1,
+ 0,
+ 1,
+ Byte.MAX_VALUE};
+ private static char [] charParamValues =
+ {Character.MIN_VALUE,
+ Character.MAX_VALUE};
+ private static double [] doubleParamValues =
+ {Double.NEGATIVE_INFINITY,
+ -1.5D,
+ -1.0D,
+ -0.0D,
+ +0.0D,
+ Double.MIN_VALUE,
+ 1.0D,
+ 1.5D,
+ Double.MAX_VALUE,
+ Double.POSITIVE_INFINITY};
+ private static float [] floatParamValues =
+ {Float.NEGATIVE_INFINITY,
+ -1.5F,
+ -1.0F,
+ -0.0F,
+ +0.0F,
+ Float.MIN_VALUE,
+ 1.0F,
+ 1.5F,
+ Float.MAX_VALUE,
+ Float.POSITIVE_INFINITY};
+ private static int [] intParamValues =
+ {Integer.MIN_VALUE,
+ -1,
+ 0,
+ 1,
+ 1234567890,
+ Integer.MAX_VALUE};
+ private static long [] longParamValues =
+ {Long.MIN_VALUE,
+ -1L,
+ 0L,
+ 1L,
+ 1234567890123456789L,
+ Long.MAX_VALUE};
+ private static short [] shortParamValues =
+ {Short.MIN_VALUE,
+ -1,
+ 0,
+ 1,
+ Short.MAX_VALUE};
+
+ public static void main(String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+ return new newinstance005().runIt(argv, out);
+ }
+
+ protected String debuggeeClassName() {
+ return newinstance005a.class.getName();
+ }
+
+ protected void doTest() {
+ initDefaultBreakpoint();
+
+ BreakpointEvent brkpEvent = forceBreakpoint();
+
+ testedClass = (ClassType )debuggee.classByName(debuggeeClassNameWithoutArgs());
+
+ thread = brkpEvent.thread();
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+
+ PrimitiveValue value = null;
+ Listnewinstance005a is deugee's part of the newinstance005.
+ */
+public class newinstance005a extends AbstractJDIDebuggee {
+
+ private static byte byteValue;
+ private static char charValue;
+ private static double doubleValue;
+ private static float floatValue;
+ private static int intValue;
+ private static long longValue;
+ private static short shortValue;
+
+ public static void main (String args[]) {
+ new newinstance005a().doTest(args);
+ }
+
+ newinstance005a() {
+
+ }
+
+ newinstance005a(byte value) {
+ byteValue = value;
+ }
+
+ newinstance005a(char value) {
+ charValue = value;
+ }
+
+ newinstance005a(double value) {
+ doubleValue = value;
+ }
+
+ newinstance005a(float value) {
+ floatValue = value;
+ }
+
+ newinstance005a(int value) {
+ intValue = value;
+ }
+
+ newinstance005a(long value) {
+ longValue = value;
+ }
+
+ newinstance005a(short value) {
+ shortValue = value;
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance006.java
new file mode 100644
index 00000000000..80eb364a686
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance006.java
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.newInstance;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * Test checks up that NullPointerException will be thrown in
+ * the following cases:
+ * - newInstance(null, method, params,ClassType.INVOKE_SINGLE_THREADED)
+ * - newInstance(thread, null, params,ClassType.INVOKE_SINGLE_THREADED)
+ * - newInstance(thread, method, null,ClassType.INVOKE_SINGLE_THREADED)
+ * In case
+ * newInstance(thread, method, params,Integer.MAX_VALUE)
+ * no exception is expected.
+ */
+
+public class newinstance006 {
+
+ private final static String prefix = "nsk.jdi.ClassType.newInstance.";
+ private final static String debuggerName = prefix + "newinstance006";
+ private final static String debugeeName = debuggerName + "a";
+
+ public final static String SGNL_READY = "ready";
+ public final static String SGNL_QUIT = "quit";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+
+ private ClassType testedClass;
+ private ThreadReference thread;
+
+ class TestRuntimeException extends RuntimeException {
+ TestRuntimeException(String msg) {
+ super("TestRuntimeException: " + msg);
+ }
+ }
+
+ public final static String method2Invoke = "justMethod";
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ newinstance006 thisTest = new newinstance006();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ thisTest.execTest();
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() {
+
+ debugee.VM().suspend();
+ testedClass = (ClassType )debugee.classByName(debugeeName);
+
+ BreakpointRequest brkp = debugee.setBreakpoint(testedClass,
+ newinstance006a.brkpMethodName,
+ newinstance006a.brkpLineNumber);
+ debugee.resume();
+
+ debugee.sendSignal("");
+ Event event = null;
+
+ // waiting the breakpoint event
+ try {
+ event = debugee.waitingEvent(brkp, waitTime);
+ } catch (InterruptedException e) {
+ throw new TestRuntimeException("unexpected InterruptedException");
+ }
+ if (!(event instanceof BreakpointEvent )) {
+ debugee.resume();
+ throw new TestRuntimeException("BreakpointEvent didn't arrive");
+ }
+
+ BreakpointEvent brkpEvent = (BreakpointEvent )event;
+
+ thread = brkpEvent.thread();
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ ObjectReference objRef;
+ List extends com.sun.jdi.Value> params = createParams(1);
+
+ Method method = getConstructor(testedClass);
+ display("Method : " + method);
+
+ display("newInstance(null, method, params,"
+ + "ClassType.INVOKE_SINGLE_THREADED)");
+ try {
+ objRef = testedClass.newInstance(null, method, params,
+ ClassType.INVOKE_SINGLE_THREADED);
+ complain("NullPointerException is not thrown");
+ exitStatus = Consts.TEST_FAILED;
+ } catch(NullPointerException e) {
+ display("!!!expected NullPointerException");
+ } catch(Exception e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ display("");
+
+ display("newInstance(thread, null, params,"
+ + "ClassType.INVOKE_SINGLE_THREADED)");
+ try {
+ objRef = testedClass.newInstance(thread, null, params,
+ ClassType.INVOKE_SINGLE_THREADED);
+ complain("NullPointerException is not thrown");
+ exitStatus = Consts.TEST_FAILED;
+ } catch(NullPointerException e) {
+ display("!!!expected NullPointerException");
+ } catch(Exception e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ display("");
+
+ display("newInstance(thread, method, null,"
+ + "ClassType.INVOKE_SINGLE_THREADED)");
+ try {
+ objRef = testedClass.newInstance(thread, method, null,
+ ClassType.INVOKE_SINGLE_THREADED);
+ complain("NullPointerException is not thrown");
+ exitStatus = Consts.TEST_FAILED;
+ } catch(NullPointerException e) {
+ display("!!!expected NullPointerException");
+ } catch(Exception e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ display("");
+
+ display("newInstance(thread, method, params,"
+ + "Integer.MAX_VALUE)");
+ try {
+ objRef = testedClass.newInstance(thread, method, params,
+ Integer.MAX_VALUE);
+ if (!objRef.referenceType().equals(testedClass)) {
+ complain("Wrong returned value " + objRef.toString());
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("returned value is " + objRef.toString());
+ }
+ } catch(Exception e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ display("");
+
+ display("newInstance(thread, method, params,"
+ + "Integer.MIN_VALUE)");
+ try {
+ objRef = testedClass.newInstance(thread, method, params,
+ Integer.MIN_VALUE);
+ if (!objRef.referenceType().equals(testedClass)) {
+ complain("Wrong returned value " + objRef.toString());
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("returned value is " + objRef.toString());
+ }
+ } catch(Exception e) {
+ complain("Unexpected " + e);
+ exitStatus = Consts.TEST_FAILED;
+ }
+ display("");
+ display("=============");
+ display("TEST FINISHES\n");
+
+ debugee.resume();
+ debugee.quit();
+ }
+
+ private List extends com.sun.jdi.Value> createParams(int size) {
+ Vectornewinstance006a is deugee's part of the newinstance006.
+ */
+public class newinstance006a {
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 47;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ Log log = new Log(System.err, argHandler);
+ IOPipe pipe = argHandler.createDebugeeIOPipe(log);
+ pipe.println(newinstance006.SGNL_READY);
+ String instr = pipe.readln();
+ log.display("breakpoint line"); // brkpLineNumber
+ instr = pipe.readln();
+ if (instr.equals(newinstance006.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+
+ newinstance006a(int val) {
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance007.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance007.java
new file mode 100644
index 00000000000..a7421d1d3d1
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance007.java
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.newInstance;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ *
+ * The test checks up the method com.sun.jdi.ClassType.newInstance()
+ *
+ * Test checks up the following assertion:
+ * ...all threads in the target VM are resumed while the method is
+ * being invoked if they were previously suspended by an event or by
+ * VirtualMachine.suspend() or ThreadReference.suspend().
+ *
+ * This checking is implemented for three cases:
+ * - when the tested thread is suspended by ThreadReference.suspend();
+ * - when the tested thread is suspended by VirtualMachine.suspend();
+ * - when the tested thread is suspended by an event.
+ */
+
+public class newinstance007 {
+
+ private final static String prefix = "nsk.jdi.ClassType.newInstance.";
+ private final static String debuggerName = prefix + "newinstance007";
+ private final static String debugeeName = debuggerName + "a";
+
+ public final static String SGNL_READY = "ready";
+ public final static String SGNL_QUIT = "quit";
+ public final static String SGNL_STRTHRD = "start_thread";
+
+ private static int exitStatus;
+ private static Log log;
+ private static Debugee debugee;
+ private static long waitTime;
+
+ private ClassType testedClass;
+ private ThreadReference thread;
+
+ class TestRuntimeException extends RuntimeException {
+ TestRuntimeException(String msg) {
+ super("TestRuntimeException: " + msg);
+ }
+ }
+
+ private static void display(String msg) {
+ log.display(msg);
+ }
+
+ private static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ newinstance007 thisTest = new newinstance007();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ thisTest.execTest();
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() {
+
+ debugee.VM().suspend();
+ testedClass = (ClassType )debugee.classByName(debugeeName);
+
+ BreakpointRequest brkp = debugee.makeBreakpoint(testedClass,
+ newinstance007a.brkpMethodName,
+ newinstance007a.brkpLineNumber);
+ brkp.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
+ brkp.enable();
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ ObjectReference objRef = null;
+ Field field = testedClass.fieldByName("invokingTime");
+ List extends com.sun.jdi.Value> params = new Vectornewinstance007a is deugee's part of the newinstance007.
+ */
+public class newinstance007a {
+
+ public final static String brkpMethodName = "main";
+ public final static int brkpLineNumber = 70;
+ public final static String testedThread = "im007aThread01";
+
+ public static Log log;
+ public static long waitTime;
+ private static IOPipe pipe;
+
+ public static void main (String argv[]) {
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(System.err, argHandler);
+ waitTime = argHandler.getWaitTime() * 60000;
+ pipe = argHandler.createDebugeeIOPipe(log);
+ im007aThread01 thread = null;
+ pipe.println(newinstance007.SGNL_READY);
+
+ String instr = pipe.readln();
+ while (!instr.equals(newinstance007.SGNL_QUIT)) {
+
+ // create new thread and start it
+ if (instr.equals(newinstance007.SGNL_STRTHRD)) {
+ thread = new im007aThread01("im007aThread01");
+ synchronized(im007aThread01.waitStarting) {
+ thread.start();
+ try {
+ im007aThread01.waitStarting.wait(waitTime);
+ log.display("checked thread started");
+ } catch (InterruptedException e) {
+ throw new Failure("Unexpected InterruptedException while waiting for checked thread start.");
+ }
+ }
+ }
+ log.display("sending ready signal...");
+ pipe.println(newinstance007.SGNL_READY);
+ log.display("waiting signal from debugger..."); // brkpLineNumber
+ instr = pipe.readln(); // this is a line for breakpoint
+
+ if (thread.isAlive()) {
+ log.display("waiting for join of : " + thread.getName());
+ try {
+ thread.join(waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("Unexpected InterruptedException while waiting for join of " + thread.getName());
+ }
+ if (thread.isAlive()) {
+ try {
+ thread.interrupt();
+ } catch (SecurityException e) {
+ throw new Failure("Cannot interrupt checked thread.");
+ }
+ }
+ }
+ }
+
+ if (instr.equals(newinstance007.SGNL_QUIT)) {
+ log.display("completed succesfully.");
+ System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
+ }
+
+ log.complain("DEBUGEE> unexpected signal of debugger.");
+ System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
+ }
+
+ private static long invokingTime;
+ newinstance007a() {
+ log.display("constructor> starting...");
+ invokingTime = 0;
+ try {
+ synchronized(im007aThread01.waitFinishing) {
+ synchronized(im007aThread01.waitInvoking) {
+ log.display("constructor> notifying to thread...");
+ im007aThread01.waitInvoking.notify();
+ }
+
+ log.display("constructor> waiting for thread's response...");
+ long startTime = System.currentTimeMillis();
+ im007aThread01.waitFinishing.wait(waitTime);
+ invokingTime = System.currentTimeMillis() - startTime;
+ return;
+ }
+ } catch (InterruptedException e) {
+ log.display("constructor> it was interrupted.");
+ }
+ invokingTime = waitTime + 1;
+ }
+}
+
+class im007aThread01 extends Thread {
+ public static Object waitInvoking = new Object();
+ public static Object waitStarting = new Object();
+ public static Object waitFinishing = new Object();
+
+ im007aThread01(String threadName) {
+ super(threadName);
+ }
+
+ public void run() {
+ synchronized(waitInvoking) {
+ synchronized(waitStarting) {
+ waitStarting.notifyAll();
+ }
+
+ newinstance007a.log.display(getName() + "> waiting for the invoked method...");
+ try {
+ long startTime = System.currentTimeMillis();
+ waitInvoking.wait(newinstance007a.waitTime);
+ if ((System.currentTimeMillis() - startTime) < newinstance007a.waitTime) {
+ newinstance007a.log.display(getName() + "> got a response from the invoked method");
+ } else {
+ newinstance007a.log.display(getName() + "*** no response from invoked method");
+ }
+ } catch (Exception e) {
+ newinstance007a.log.display(getName() + e);
+ }
+ }
+ synchronized(waitFinishing) {
+ newinstance007a.log.display(getName() + "> notifying to invoked method...");
+ waitFinishing.notify();
+ }
+ newinstance007a.log.display(getName() + "> thread finished");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance008.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance008.java
new file mode 100644
index 00000000000..e0a990e7ca4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance008.java
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2002, 2018, 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.
+ */
+
+package nsk.jdi.ClassType.newInstance;
+
+import nsk.share.*;
+import nsk.share.jpda.*;
+import nsk.share.jdi.*;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.jdi.event.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ *
+ * The test checks up the method com.sun.jdi.ClassType.newInstance()
+ *
+ * Test checks up the following assertion:
+ * If the target VM is disconnected during the invoke (for example,
+ * through VirtualMachine.dispose()) the method invocation continues.
+ */
+
+public class newinstance008 {
+
+ private final static String prefix = "nsk.jdi.ClassType.newInstance.";
+ private final static String debuggerName = prefix + "newinstance008";
+ private final static String debugeeName = debuggerName + "a";
+
+ public final static String SGNL_READY = "ready";
+ public final static String SGNL_QUIT = "quit";
+ public final static String SGNL_FINISH = "finish";
+ public final static String SGNL_ABORT = "abort";
+
+ public static int exitStatus;
+ public static Log log;
+ public static Debugee debugee;
+ public static long waitTime;
+ private static boolean isAborted = false;
+
+ private ClassType testedClass;
+
+ public static void display(String msg) {
+ log.display(msg);
+ }
+
+ public static void complain(String msg) {
+ log.complain("debugger FAILURE> " + msg + "\n");
+ }
+
+ public static void main(String argv[]) {
+ System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
+ }
+
+ public static int run(String argv[], PrintStream out) {
+
+ exitStatus = Consts.TEST_PASSED;
+
+ newinstance008 thisTest = new newinstance008();
+
+ ArgumentHandler argHandler = new ArgumentHandler(argv);
+ log = new Log(out, argHandler);
+
+ waitTime = argHandler.getWaitTime() * 60000;
+
+ debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
+
+ try {
+ thisTest.execTest();
+ } catch (Failure e) {
+ exitStatus = Consts.TEST_FAILED;
+ e.printStackTrace();
+ } finally {
+ if (!isAborted) {
+ debugee.resume();
+ debugee.quit();
+ }
+ }
+
+ display("Test finished. exitStatus = " + exitStatus);
+
+ return exitStatus;
+ }
+
+ private void execTest() throws Failure{
+
+ debugee.VM().suspend();
+ testedClass = (ClassType )debugee.classByName(debugeeName);
+
+ display("\nTEST BEGINS");
+ display("===========");
+
+ InvokingThread invokeThrd = new InvokingThread();
+ invokeThrd.start();
+
+ // waiting READY signal from invoked constructor
+ display("\nwaiting for signal \""
+ + SGNL_READY
+ + "\" from the invoked constructor");
+ debugee.receiveExpectedSignal(SGNL_READY);
+
+ display("\nConstructor has been invoked. Trying to dispose debugee's VM");
+
+ AbortingThread abortingThrd = new AbortingThread();
+ abortingThrd.start();
+
+ debugee.VM().dispose();
+ invokeThrd.waitVMDisconnect();
+
+ try {
+ invokeThrd.join();
+ } catch(InterruptedException e) {
+ throw new Failure("unexpected " + e);
+ }
+
+ if (isAborted) {
+ complain("Debugee's VM disposing hung. Invoking was aborted!!!");
+ exitStatus = Consts.TEST_FAILED;
+ } else {
+ display("\nVirtual machine has been disposed");
+ display("sending signal \"" + SGNL_FINISH + "\" to the invoked constructor");
+ debugee.sendSignal(SGNL_FINISH);
+ }
+
+ display("\n=============");
+ display("TEST FINISHES\n");
+ }
+
+ private BreakpointEvent waitForBreakpoint(BreakpointRequest brkp) {
+ Event event = null;
+ BreakpointEvent brkpEvent;
+
+ try {
+ event = debugee.waitingEvent(brkp, waitTime);
+ } catch (InterruptedException e) {
+ throw new Failure("unexpected " + e);
+ }
+
+ if (!(event instanceof BreakpointEvent )) {
+ debugee.resume();
+ throw new Failure("BreakpointEvent didn't arrive");
+ }
+
+ brkpEvent = (BreakpointEvent )event;
+ return brkpEvent;
+ }
+
+ private Method getConstructor(ReferenceType classType) {
+ List methodList = classType.methods();
+ Method method;
+ for (int i = 0; i < methodList.size(); i++) {
+ method = (Method )methodList.get(i);
+ if (method.isConstructor()) {
+ return method;
+ }
+ }
+ return null;
+ }
+
+ class InvokingThread extends Thread {
+ volatile boolean isNotified = false;
+
+ public void run() {
+ display("");
+ BreakpointRequest brkp = debugee.setBreakpoint(testedClass,
+ newinstance008a.brkpMethodName,
+ newinstance008a.brkpLineNumber);
+ debugee.resume();
+
+ debugee.sendSignal("");
+
+ BreakpointEvent brkpEvent = waitForBreakpoint(brkp);
+ ThreadReference thread = brkpEvent.thread();
+
+ Value retValue;
+ List extends com.sun.jdi.Value> params = new Vector