8199383: [TESTBUG] Open source VM testbase JVMTI tests

Reviewed-by: sspitsyn, erikj
This commit is contained in:
Igor Ignatyev 2018-05-24 17:12:15 -07:00
parent 207e005711
commit 59ac4c2629
2767 changed files with 308252 additions and 0 deletions
make/test
test/hotspot/jtreg
ProblemList-graal.txtProblemList.txtTEST.groups
vmTestbase/nsk/jvmti
AddCapabilities
AddToBootstrapClassLoaderSearch
AddToSystemClassLoaderSearch
Agent_OnLoad
Agent_OnUnload
Allocate
AttachOnDemand

File diff suppressed because it is too large Load Diff

@ -86,6 +86,7 @@ compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessPro
compiler/jvmci/events/JvmciShutdownEventTest.java CODETOOLS-7902162 generic-all
vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn009/forceEarlyReturn009.java 8191047 generic-all
vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/TestDescription.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
@ -139,3 +140,12 @@ vmTestbase/nsk/jdb/wherei/wherei001/wherei001.java
vmTestbase/vm/mlvm/anonloader/stress/oome/heap/Test.java 8186299 generic-all
vmTestbase/vm/mlvm/anonloader/stress/oome/metaspace/Test.java 8186299 generic-all
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-tagged/TestDescription.java 8193577 generic-all
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-class-tagged/TestDescription.java 8193577 generic-all
vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretbase/TestDescription.java 8195635 generic-all
vmTestbase/nsk/jvmti/PopFrame/popframe009/TestDescription.java 8195639 generic-all
vmTestbase/nsk/jvmti/ForceEarlyReturn/ForceEarlyReturn002/TestDescription.java 8195674 generic-all

@ -128,6 +128,24 @@ vmTestbase/metaspace/gc/firstGC_50m/TestDescription.java 8160008 generic-all
vmTestbase/metaspace/gc/firstGC_99m/TestDescription.java 8160008 generic-all
vmTestbase/metaspace/gc/firstGC_default/TestDescription.java 8160008 generic-all
vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk001/TestDescription.java 8016181 generic-all
vmTestbase/nsk/jvmti/FieldModification/fieldmod001/TestDescription.java 8016181 generic-all
vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted001/TestDescription.java 7013634 generic-all
vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted003/TestDescription.java 6606767 generic-all
vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted004/TestDescription.java 7013634,6606767 generic-all
vmTestbase/nsk/jvmti/ThreadStart/threadstart001/TestDescription.java 8016181 generic-all
vmTestbase/nsk/jvmti/ThreadStart/threadstart003/TestDescription.java 8034084 generic-all
vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/TestDescription.java 8173658 generic-all
vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t001/hs204t001.java 6813266 generic-all
vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/TestDescription.java 8051349 generic-all
vmTestbase/nsk/jvmti/AttachOnDemand/attach034/TestDescription.java 8042145 generic-all
vmTestbase/nsk/jvmti/AttachOnDemand/attach045/TestDescription.java 8202971 generic-all
vmTestbase/nsk/jvmti/unit/heap/HeapWalkTests/TestDescription.java 8016181 generic-all
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-tagged/TestDescription.java 8201513 generic-all
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-class-untagged/TestDescription.java 8201513 generic-all
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-class-tagged/TestDescription.java 8201513 generic-all
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-untagged/TestDescription.java 8201513 generic-all
vmTestbase/gc/lock/jni/jnilock002/TestDescription.java 8191869,8192647 generic-all
vmTestbase/vm/mlvm/indy/func/jdi/breakpointOtherStratum/Test.java 8199578 generic-all

@ -1166,6 +1166,590 @@ vmTestbase_nsk_jdi_quick = \
vmTestbase_vm_metaspace = \
vmTestbase/metaspace
# JVMTI tests
vmTestbase_nsk_jvmti = \
vmTestbase/nsk/jvmti
vmTestbase_nsk_jvmti_quick = \
vmTestbase/nsk/jvmti/AddCapabilities/addcaps001/TestDescription.java \
vmTestbase/nsk/jvmti/AddCapabilities/addcaps002/TestDescription.java \
vmTestbase/nsk/jvmti/AddCapabilities/addcaps003/TestDescription.java \
vmTestbase/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch001/TestDescription.java \
vmTestbase/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch002/TestDescription.java \
vmTestbase/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch003/TestDescription.java \
vmTestbase/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch004/TestDescription.java \
vmTestbase/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch007/TestDescription.java \
vmTestbase/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch008/TestDescription.java \
vmTestbase/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch009/TestDescription.java \
vmTestbase/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch010/TestDescription.java \
vmTestbase/nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch001/TestDescription.java \
vmTestbase/nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch002/TestDescription.java \
vmTestbase/nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch003/TestDescription.java \
vmTestbase/nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch004/TestDescription.java \
vmTestbase/nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch005/TestDescription.java \
vmTestbase/nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch006/TestDescription.java \
vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload001/TestDescription.java \
vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload002/TestDescription.java \
vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload003/TestDriver.java \
vmTestbase/nsk/jvmti/Agent_OnUnload/agentonunload001/TestDriver.java \
vmTestbase/nsk/jvmti/Breakpoint/breakpoint001/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk001/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk002/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk003/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk004/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk005/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk006/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk007/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk008/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk009/TestDescription.java \
vmTestbase/nsk/jvmti/ClassLoad/classload001/TestDescription.java \
vmTestbase/nsk/jvmti/ClassPrepare/classprep001/TestDescription.java \
vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk001/TestDescription.java \
vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk002/TestDescription.java \
vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk005/TestDescription.java \
vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001/TestDescription.java \
vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw002/TestDescription.java \
vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001/TestDescription.java \
vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw002/TestDescription.java \
vmTestbase/nsk/jvmti/CompiledMethodLoad/compmethload001/TestDescription.java \
vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon001/TestDescription.java \
vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon002/TestDescription.java \
vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv001/TestDescription.java \
vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv002/TestDescription.java \
vmTestbase/nsk/jvmti/Deallocate/dealloc001/TestDescription.java \
vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon001/TestDescription.java \
vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon003/TestDescription.java \
vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon004/TestDescription.java \
vmTestbase/nsk/jvmti/DynamicCodeGenerated/dyncodgen001/TestDescription.java \
vmTestbase/nsk/jvmti/Exception/exception001/TestDescription.java \
vmTestbase/nsk/jvmti/ExceptionCatch/excatch001/TestDescription.java \
vmTestbase/nsk/jvmti/FieldAccess/fieldacc001/TestDescription.java \
vmTestbase/nsk/jvmti/FieldAccess/fieldacc002/TestDescription.java \
vmTestbase/nsk/jvmti/FieldAccess/fieldacc003/TestDescription.java \
vmTestbase/nsk/jvmti/FieldAccess/fieldacc004/TestDescription.java \
vmTestbase/nsk/jvmti/FieldModification/fieldmod001/TestDescription.java \
vmTestbase/nsk/jvmti/FieldModification/fieldmod002/TestDescription.java \
vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc001/TestDescription.java \
vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc002/TestDescription.java \
vmTestbase/nsk/jvmti/FramePop/framepop001/TestDescription.java \
vmTestbase/nsk/jvmti/FramePop/framepop002/TestDescription.java \
vmTestbase/nsk/jvmti/GenerateEvents/genevents001/TestDescription.java \
vmTestbase/nsk/jvmti/GetAllThreads/allthr001/TestDescription.java \
vmTestbase/nsk/jvmti/GetAllThreads/allthr002/TestDescription.java \
vmTestbase/nsk/jvmti/GetAvailableProcessors/getavailproc001/TestDescription.java \
vmTestbase/nsk/jvmti/GetArgumentsSize/argsize001/TestDescription.java \
vmTestbase/nsk/jvmti/GetArgumentsSize/argsize002/TestDescription.java \
vmTestbase/nsk/jvmti/GetBytecodes/bytecodes001/TestDescription.java \
vmTestbase/nsk/jvmti/GetBytecodes/bytecodes002/TestDescription.java \
vmTestbase/nsk/jvmti/GetBytecodes/bytecodes003/TestDescription.java \
vmTestbase/nsk/jvmti/GetCapabilities/getcaps001/TestDescription.java \
vmTestbase/nsk/jvmti/GetCapabilities/getcaps002/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassFields/getclfld005/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassFields/getclfld006/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassFields/getclfld007/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassLoader/getclsldr001/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassLoader/getclsldr002/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassLoader/getclsldr003/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss001/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassMethods/getclmthd005/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassMethods/getclmthd006/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassMethods/getclmthd007/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf004/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf005/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf006/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf007/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassSignature/getclsig004/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassSignature/getclsig005/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassSignature/getclsig006/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassStatus/getclstat005/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassStatus/getclstat006/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassStatus/getclstat007/TestDescription.java \
vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon001/TestDescription.java \
vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon002/TestDescription.java \
vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon003/TestDescription.java \
vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/TestDescription.java \
vmTestbase/nsk/jvmti/GetCurrentThreadCpuTimerInfo/curthrtimerinfo001/TestDescription.java \
vmTestbase/nsk/jvmti/GetEnvironmentLocalStorage/getenvstor001/TestDescription.java \
vmTestbase/nsk/jvmti/GetErrorName/geterrname001/TestDescription.java \
vmTestbase/nsk/jvmti/GetErrorName/geterrname002/TestDescription.java \
vmTestbase/nsk/jvmti/GetExtensionEvents/extevents001/TestDescription.java \
vmTestbase/nsk/jvmti/GetExtensionFunctions/extfuncs001/TestDescription.java \
vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl001/TestDescription.java \
vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl002/TestDescription.java \
vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl004/TestDescription.java \
vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf003/TestDescription.java \
vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf004/TestDescription.java \
vmTestbase/nsk/jvmti/GetFieldName/getfldnm003/TestDescription.java \
vmTestbase/nsk/jvmti/GetFieldName/getfldnm004/TestDescription.java \
vmTestbase/nsk/jvmti/GetFieldName/getfldnm005/TestDescription.java \
vmTestbase/nsk/jvmti/GetFrameCount/framecnt001/TestDescription.java \
vmTestbase/nsk/jvmti/GetFrameCount/framecnt002/TestDescription.java \
vmTestbase/nsk/jvmti/GetFrameCount/framecnt003/TestDescription.java \
vmTestbase/nsk/jvmti/GetFrameLocation/frameloc002/TestDescription.java \
vmTestbase/nsk/jvmti/GetFrameLocation/frameloc003/TestDescription.java \
vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf005/TestDescription.java \
vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf006/TestDescription.java \
vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/TestDescription.java \
vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt001/TestDescription.java \
vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt002/TestDescription.java \
vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab001/TestDescription.java \
vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab002/TestDescription.java \
vmTestbase/nsk/jvmti/GetLineNumberTable/linetab001/TestDescription.java \
vmTestbase/nsk/jvmti/GetLineNumberTable/linetab002/TestDescription.java \
vmTestbase/nsk/jvmti/GetLineNumberTable/linetab003/TestDescription.java \
vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss001/TestDescription.java \
vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss002/TestDescription.java \
vmTestbase/nsk/jvmti/GetLocalVariable/getlocal001/TestDescription.java \
vmTestbase/nsk/jvmti/GetLocalVariable/getlocal002/TestDescription.java \
vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab001/TestDescription.java \
vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab002/TestDescription.java \
vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab003/TestDescription.java \
vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab004/TestDescription.java \
vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab005/TestDescription.java \
vmTestbase/nsk/jvmti/GetMaxLocals/maxloc001/TestDescription.java \
vmTestbase/nsk/jvmti/GetMaxLocals/maxloc002/TestDescription.java \
vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls001/TestDescription.java \
vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls002/TestDescription.java \
vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls003/TestDescription.java \
vmTestbase/nsk/jvmti/GetObjectHashCode/objhashcode001/TestDescription.java \
vmTestbase/nsk/jvmti/GetMethodLocation/methloc001/TestDescription.java \
vmTestbase/nsk/jvmti/GetMethodLocation/methloc002/TestDescription.java \
vmTestbase/nsk/jvmti/GetMethodModifiers/methmod001/TestDescription.java \
vmTestbase/nsk/jvmti/GetMethodModifiers/methmod002/TestDescription.java \
vmTestbase/nsk/jvmti/GetMethodName/methname001/TestDescription.java \
vmTestbase/nsk/jvmti/GetMethodName/methname002/TestDescription.java \
vmTestbase/nsk/jvmti/GetMethodName/methname003/TestDescription.java \
vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage001/TestDescription.java \
vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage002/TestDescription.java \
vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage003/TestDescription.java \
vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage004/TestDescription.java \
vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage005/TestDescription.java \
vmTestbase/nsk/jvmti/GetObjectSize/objsize001/TestDescription.java \
vmTestbase/nsk/jvmti/GetObjectsWithTags/objwithtags001/TestDescription.java \
vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf001/TestDescription.java \
vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf002/TestDescription.java \
vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf003/TestDescription.java \
vmTestbase/nsk/jvmti/GetPhase/getphase001/TestDescription.java \
vmTestbase/nsk/jvmti/GetPhase/getphase002/TestDescription.java \
vmTestbase/nsk/jvmti/GetPotentialCapabilities/getpotcaps001/TestDescription.java \
vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex001/TestDescription.java \
vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex002/TestDescription.java \
vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex003/TestDescription.java \
vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn004/TestDescription.java \
vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn005/TestDescription.java \
vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn006/TestDescription.java \
vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops001/TestDescription.java \
vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops002/TestDescription.java \
vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop001/TestDescription.java \
vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop002/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr001/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr002/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr003/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr004/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr005/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr006/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr007/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr008/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr009/TestDescription.java \
vmTestbase/nsk/jvmti/GetTag/gettag001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime002/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadCpuTimerInfo/thrtimerinfo001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadGroupChildren/getthrdgrpchld001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo002/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo002/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadLocalStorage/getthrdstor001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadState/thrstat001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadState/thrstat002/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadState/thrstat003/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadState/thrstat004/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadState/thrstat005/TestDescription.java \
vmTestbase/nsk/jvmti/GetTime/gettime001/TestDescription.java \
vmTestbase/nsk/jvmti/GetTimerInfo/timerinfo001/TestDescription.java \
vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp001/TestDescription.java \
vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp002/TestDescription.java \
vmTestbase/nsk/jvmti/GetVersionNumber/getvern001/TestDescription.java \
vmTestbase/nsk/jvmti/InterruptThread/intrpthrd001/TestDescription.java \
vmTestbase/nsk/jvmti/InterruptThread/intrpthrd002/TestDescription.java \
vmTestbase/nsk/jvmti/InterruptThread/intrpthrd003/TestDescription.java \
vmTestbase/nsk/jvmti/IsArrayClass/isarray004/TestDescription.java \
vmTestbase/nsk/jvmti/IsArrayClass/isarray005/TestDescription.java \
vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin002/TestDescription.java \
vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin003/TestDescription.java \
vmTestbase/nsk/jvmti/IsInterface/isintrf004/TestDescription.java \
vmTestbase/nsk/jvmti/IsInterface/isintrf005/TestDescription.java \
vmTestbase/nsk/jvmti/IsMethodNative/isnative001/TestDescription.java \
vmTestbase/nsk/jvmti/IsMethodNative/isnative002/TestDescription.java \
vmTestbase/nsk/jvmti/IsMethodObsolete/isobsolete001/TestDescription.java \
vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth001/TestDescription.java \
vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth002/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverHeap/iterheap001/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverHeap/iterheap002/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverHeap/iterheap003/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverHeap/iterheap004/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverHeap/iterheap005/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverHeap/iterheap006/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverHeap/iterheap007/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls001/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls002/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls003/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls004/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls005/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls006/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls007/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj001/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj002/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj003/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj004/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj005/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj001/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj002/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj003/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj004/TestDescription.java \
vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj005/TestDescription.java \
vmTestbase/nsk/jvmti/IterateThroughHeap/callbacks/Callbacks.java \
vmTestbase/nsk/jvmti/IterateThroughHeap/concrete-klass-filter/TestDescription.java \
vmTestbase/nsk/jvmti/IterateThroughHeap/non-concrete-klass-filter/TestDescription.java \
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-tagged/TestDescription.java \
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-untagged/TestDescription.java \
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-class-tagged/TestDescription.java \
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-class-untagged/TestDescription.java \
vmTestbase/nsk/jvmti/IterateThroughHeap/abort/Abort.java \
vmTestbase/nsk/jvmti/MethodEntry/mentry001/TestDescription.java \
vmTestbase/nsk/jvmti/MethodEntry/mentry002/TestDescription.java \
vmTestbase/nsk/jvmti/MethodExit/mexit002/TestDescription.java \
vmTestbase/nsk/jvmti/MonitorContendedEnter/mcontenter001/TestDescription.java \
vmTestbase/nsk/jvmti/MonitorContendedEntered/mcontentered001/TestDescription.java \
vmTestbase/nsk/jvmti/MonitorWait/monitorwait001/TestDescription.java \
vmTestbase/nsk/jvmti/MonitorWaited/monitorwaited001/TestDescription.java \
vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/TestDescription.java \
vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/TestDescription.java \
vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/TestDescription.java \
vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/TestDescription.java \
vmTestbase/nsk/jvmti/NotifyFramePop/nframepop001/TestDescription.java \
vmTestbase/nsk/jvmti/NotifyFramePop/nframepop002/TestDescription.java \
vmTestbase/nsk/jvmti/NotifyFramePop/nframepop003/TestDescription.java \
vmTestbase/nsk/jvmti/ObjectFree/objfree002/TestDescription.java \
vmTestbase/nsk/jvmti/PopFrame/popframe001/TestDescription.java \
vmTestbase/nsk/jvmti/PopFrame/popframe002/TestDescription.java \
vmTestbase/nsk/jvmti/PopFrame/popframe003/TestDescription.java \
vmTestbase/nsk/jvmti/PopFrame/popframe004/TestDescription.java \
vmTestbase/nsk/jvmti/PopFrame/popframe005/TestDescription.java \
vmTestbase/nsk/jvmti/PopFrame/popframe006/TestDescription.java \
vmTestbase/nsk/jvmti/PopFrame/popframe007/TestDescription.java \
vmTestbase/nsk/jvmti/PopFrame/popframe008/TestDescription.java \
vmTestbase/nsk/jvmti/PopFrame/popframe009/TestDescription.java \
vmTestbase/nsk/jvmti/PopFrame/popframe010/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter001/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter002/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter003/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter004/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit001/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit002/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit003/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit005/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy001/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy002/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy003/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy004/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall001/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall002/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall003/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall004/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait001/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait002/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait003/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait004/TestDescription.java \
vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait005/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/StressRedefineWithoutBytecodeCorruption/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass001/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass002/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass003/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass004/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass005/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass006/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass008/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass009/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass010/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass011/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass012/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass013/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass014/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass015/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass016/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass017/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass018/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass019/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass020/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass021/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass022/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass023/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass024/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass025/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass026/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass027/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass028/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass029/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass030/TestDescription.java \
vmTestbase/nsk/jvmti/RedefineClasses/redefclass031/TestDescription.java \
vmTestbase/nsk/jvmti/RelinquishCapabilities/relcaps001/TestDescription.java \
vmTestbase/nsk/jvmti/RelinquishCapabilities/relcaps002/TestDescription.java \
vmTestbase/nsk/jvmti/ResumeThread/resumethrd001/TestDescription.java \
vmTestbase/nsk/jvmti/ResumeThread/resumethrd002/TestDescription.java \
vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst001/TestDescription.java \
vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst002/TestDescription.java \
vmTestbase/nsk/jvmti/RunAgentThread/agentthr001/TestDescription.java \
vmTestbase/nsk/jvmti/RunAgentThread/agentthr002/TestDescription.java \
vmTestbase/nsk/jvmti/RunAgentThread/agentthr003/TestDescription.java \
vmTestbase/nsk/jvmti/SetBreakpoint/setbrk002/TestDescription.java \
vmTestbase/nsk/jvmti/SetBreakpoint/setbrk003/TestDescription.java \
vmTestbase/nsk/jvmti/SetBreakpoint/setbrk005/TestDescription.java \
vmTestbase/nsk/jvmti/SetBreakpoint/setbrk007/TestDescription.java \
vmTestbase/nsk/jvmti/SetBreakpoint/setbrk008/TestDescription.java \
vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor001/TestDescription.java \
vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor002/TestDescription.java \
vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor003/TestDescription.java \
vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb001/TestDescription.java \
vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb002/TestDescription.java \
vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb003/TestDescription.java \
vmTestbase/nsk/jvmti/SetEventNotificationMode/setnotif001/TestDescription.java \
vmTestbase/nsk/jvmti/SetExtensionEventCallback/setextevent001/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw002/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw003/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw004/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw005/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw006/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw002/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw003/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw004/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw005/TestDescription.java \
vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw006/TestDescription.java \
vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/TestDescription.java \
vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab002/TestDescription.java \
vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/TestDescription.java \
vmTestbase/nsk/jvmti/SetLocalVariable/setlocal002/TestDescription.java \
vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/TestDescription.java \
vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/TestDescription.java \
vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop002/TestDescription.java \
vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop003/TestDescription.java \
vmTestbase/nsk/jvmti/SetTag/settag001/TestDescription.java \
vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor001/TestDescription.java \
vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor002/TestDescription.java \
vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor003/TestDescription.java \
vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag001/TestDescription.java \
vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag002/TestDescription.java \
vmTestbase/nsk/jvmti/SingleStep/singlestep001/TestDescription.java \
vmTestbase/nsk/jvmti/SingleStep/singlestep003/TestDescription.java \
vmTestbase/nsk/jvmti/SuspendThread/suspendthrd001/TestDescription.java \
vmTestbase/nsk/jvmti/SuspendThreadList/suspendthrdlst001/TestDescription.java \
vmTestbase/nsk/jvmti/StopThread/stopthrd006/TestDescription.java \
vmTestbase/nsk/jvmti/StopThread/stopthrd007/TestDescription.java \
vmTestbase/nsk/jvmti/ThreadEnd/threadend001/TestDescription.java \
vmTestbase/nsk/jvmti/ThreadEnd/threadend002/TestDescription.java \
vmTestbase/nsk/jvmti/ThreadStart/threadstart001/TestDescription.java \
vmTestbase/nsk/jvmti/ThreadStart/threadstart002/TestDescription.java \
vmTestbase/nsk/jvmti/ThreadStart/threadstart003/TestDescription.java \
vmTestbase/nsk/jvmti/VMDeath/vmdeath001/TestDescription.java \
vmTestbase/nsk/jvmti/VMInit/vminit001/TestDescription.java \
vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP01/ap01t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP02/ap02t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP03/ap03t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP05/ap05t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP05/ap05t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP06/ap06t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP07/ap07t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP07/ap07t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP09/ap09t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP10/ap10t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/bcinstr/BI02/bi02t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/bcinstr/BI02/bi02t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/bcinstr/BI03/bi03t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/bcinstr/BI03/bi03t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t003/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t004/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t005/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t006/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t008/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t009/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t010/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t011/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t012/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t013/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t014/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t015/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t016/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t017/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t018/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t019/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t020/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t021/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/capability/CM02/cm02t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/contention/TC01/tc01t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/contention/TC02/tc02t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t004/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t008/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t009/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM04/em04t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM05/em05t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM06/em06t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/general_functions/GF01/gf01t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/general_functions/GF04/gf04t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/general_functions/GF06/gf06t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t001/TestDriver.java \
vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t003/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS101/hs101t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS101/hs101t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS101/hs101t003/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS101/hs101t004/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS101/hs101t005/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS101/hs101t006/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS101/hs101t007/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS101/hs101t008/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS102/hs102t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS102/hs102t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS103/hs103t002/hs103t002.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS104/hs104t001/hs104t001.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS104/hs104t002/hs104t002.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t003/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t001/hs202t001.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t002/hs202t002.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t001/hs203t001.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t002/hs203t002.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t003/hs203t003.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t002/hs204t002.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t003/hs204t003.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t004/hs204t004.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t001/hs301t001.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t002/hs301t002.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t003/hs301t003.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t004/hs301t004.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t005/hs301t005.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t001/hs302t001.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t002/hs302t002.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t003/hs302t003.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t004/hs302t004.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t005/hs302t005.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t006/hs302t006.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t007/hs302t007.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t008/hs302t008.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t009/hs302t009.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t010/hs302t010.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t011/hs302t011.java \
vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t012/hs302t012.java \
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI01/ji01t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t003/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA01/ma01t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA02/ma02t001/TestDriver.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA03/ma03t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t003/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA05/ma05t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA06/ma06t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA07/ma07t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/TestDescription.java \
vmTestbase/nsk/jvmti/AttachOnDemand/attach002a/TestDescription.java \
vmTestbase/nsk/jvmti/AttachOnDemand/attach024/TestDescription.java \
vmTestbase/nsk/jvmti/RetransformClasses/retransform002/TestDescription.java \
vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java \
vmTestbase/nsk/jvmti/RetransformClasses/retransform004/TestDescription.java \
vmTestbase/nsk/jvmti/ForceEarlyReturn/ForceEarlyReturn001/TestDescription.java \
vmTestbase/nsk/jvmti/ForceEarlyReturn/ForceEarlyReturn002/TestDescription.java \
vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix001/TestDescription.java \
vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java \
vmTestbase/nsk/jvmti/GetEnv/GetEnv001/GetEnv001.java \
vmTestbase/nsk/jvmti/unit/MethodBind/JvmtiTest/TestDescription.java \
vmTestbase/nsk/jvmti/unit/OnUnload/JvmtiTest/TestDescription.java \
vmTestbase/nsk/jvmti/unit/StackTrace/JvmtiTest/TestDescription.java \
vmTestbase/nsk/jvmti/unit/agentthr/TestDescription.java \
vmTestbase/nsk/jvmti/unit/clsldrclss00x/TestDescription.java \
vmTestbase/nsk/jvmti/unit/events/redefineCFLH/JvmtiTest/TestDescription.java \
vmTestbase/nsk/jvmti/unit/extmech/TestDescription.java \
vmTestbase/nsk/jvmti/unit/functions/AddToBootstrapClassLoaderSearch/JvmtiTest/TestDescription.java \
vmTestbase/nsk/jvmti/unit/functions/Dispose/JvmtiTest/TestDescription.java \
vmTestbase/nsk/jvmti/unit/functions/environment/JvmtiTest/TestDescription.java \
vmTestbase/nsk/jvmti/unit/functions/nosuspendMonitorInfo/JvmtiTest/TestDescription.java \
vmTestbase/nsk/jvmti/unit/functions/nosuspendStackTrace/JvmtiTest/TestDescription.java \
vmTestbase/nsk/jvmti/unit/functions/rawmonitor/TestDescription.java \
vmTestbase/nsk/jvmti/unit/heap/BasicIterationTests/TestDescription.java \
vmTestbase/nsk/jvmti/unit/heap/BasicTagTests/TestDescription.java \
vmTestbase/nsk/jvmti/unit/heap/GetWithTests/TestDescription.java \
vmTestbase/nsk/jvmti/unit/heap/HeapWalkTests/TestDescription.java \
vmTestbase/nsk/jvmti/unit/heap/ObjectFreeTests/TestDescription.java \
vmTestbase/nsk/jvmti/unit/heap/ObjectSizeTests/TestDescription.java \
vmTestbase/nsk/jvmti/unit/heapref/TestDescription.java \
vmTestbase/nsk/jvmti/unit/refignore/TestDescription.java \
vmTestbase/nsk/jvmti/unit/setNullVMInit/JvmtiTest/TestDescription.java \
vmTestbase/nsk/jvmti/unit/GetLineNumberTable/linetab004/TestDescription.java \
vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/TestDescription.java \
vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal004/TestDescription.java \
vmTestbase/nsk/jvmti/unit/IsSynthetic/issynth001/TestDescription.java \
vmTestbase/nsk/jvmti/unit/FollowReferences/followref001/TestDescription.java \
vmTestbase/nsk/jvmti/unit/FollowReferences/followref002/TestDescription.java \
vmTestbase/nsk/jvmti/unit/FollowReferences/followref003/TestDescription.java \
vmTestbase/nsk/jvmti/unit/FollowReferences/followref004/TestDescription.java \
vmTestbase/nsk/jvmti/unit/FollowReferences/followref005/TestDescription.java \
vmTestbase/nsk/jvmti/unit/FollowReferences/followref006/TestDescription.java \
vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretbase/TestDescription.java \
vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretfp/TestDescription.java \
vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretint/TestDescription.java \
vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretlong/TestDescription.java \
vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretobj/TestDescription.java \
vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretstr/TestDescription.java \
vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretvoid/TestDescription.java \
vmTestbase/nsk/jvmti/unit/GetAllStackTraces/getallstktr001/TestDescription.java \
vmTestbase/nsk/jvmti/unit/GetConstantPool/getcpool001/TestDescription.java
vmTestbase_nsk_stress = \
vmTestbase/nsk/stress

@ -0,0 +1,71 @@
/*
* Copyright (c) 2003, 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.jvmti.AddCapabilities;
import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
public class addcaps001 extends DebugeeClass {
// load native library if required
static {
System.loadLibrary("addcaps001");
}
// run test from command line
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
// run test from JCK-compatible environment
public static int run(String argv[], PrintStream out) {
return new addcaps001().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
ArgumentHandler argHandler = null;
Log log = null;
long timeout = 0;
int status = Consts.TEST_PASSED;
// run debuggee
public int runIt(String argv[], PrintStream out) {
argHandler = new ArgumentHandler(argv);
log = new Log(out, argHandler);
timeout = argHandler.getWaitTime() * 60 * 1000; // milliseconds
// testing sync
log.display("Sync: debugee ready");
status = checkStatus(status);
return status;
}
}

@ -0,0 +1,59 @@
/*
* 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/jvmti/AddCapabilities/addcaps001.
* VM Testbase keywords: [quick, jpda, jvmti, noras]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function GetCapabilities().
* This test checks that AddCapabilities() adds no capabilities being
* invoked with empty capabilities list in Agent_OnLoad().
* This is checked by GetCapabilities either on OnLoad and live phases.
* In verbose mode the test prints obtained capabilities either as raw bits
* and as values of known capabilities.
* The following checks are performed for AddCapabilities():
* - in JVM_OnLoad() on OnLoad phase
* The following checks are performed for GetCapabilities():
* - in JVM_OnLoad() on OnLoad phase
* - in VM_INIT event on live phase
* - in agent thread on live phase
* - in VM_DEATH callback on live phase
* The test passes if AddCapabilities() returns no error code and
* GetCapabilities() returns structure with no capabilities set
* in all checks.
* If the last check (in VM_DEATH callback) fails, then C-language exit()
* function is used to force VM exit with fail status 97.
* COMMENTS
* Modified due to fix of the rfe
* 5010823 TEST_RFE: some JVMTI tests use the replaced capability
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/native -agentlib:addcaps001=-waittime=5 nsk.jvmti.AddCapabilities.addcaps001
*/

@ -0,0 +1,353 @@
/*
* Copyright (c) 2003, 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.
*/
#include <stdlib.h>
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "jni_tools.h"
#include "jvmti_tools.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================================= */
static jlong timeout = 0;
#define STATUS_FAIL 97
#define EVENTS_COUNT 2
static jvmtiEvent events[EVENTS_COUNT] = {
JVMTI_EVENT_VM_INIT,
JVMTI_EVENT_VM_DEATH
};
static jvmtiCapabilities initCaps;
/* ============================================================================= */
/** Prints capabilities structure as raw bits. */
static void printRawCapabilities(const jvmtiCapabilities* caps) {
const unsigned char* p = (const unsigned char*)caps;
int size = (int) sizeof(jvmtiCapabilities);
int i, j, k;
nsk_printf(" ");
for (j = 0; j < 16; j++) {
nsk_printf(" %1X", j);
}
nsk_printf("\n");
for (i = 0; i < size; i += 2) {
int prefix = i / 2;
nsk_printf(" 0x%03X.: ", prefix);
for (k = 0; k < 2; k++) {
unsigned char b = *(p++);
for (j = 0; j < 8; j++) {
int bit = b % 2;
b /= 2;
nsk_printf(" %1d", bit);
}
}
nsk_printf("\n");
}
}
#define PRINT_CAP(caps, name) nsk_printf(" %-40s: %d\n", #name, (int)caps->name)
/** Print values of known capabilities. */
static void printKnownCapabilities(const jvmtiCapabilities* caps) {
PRINT_CAP(caps, can_tag_objects);
PRINT_CAP(caps, can_generate_field_modification_events);
PRINT_CAP(caps, can_generate_field_access_events);
PRINT_CAP(caps, can_get_bytecodes);
PRINT_CAP(caps, can_get_synthetic_attribute);
PRINT_CAP(caps, can_get_owned_monitor_info);
PRINT_CAP(caps, can_get_current_contended_monitor);
PRINT_CAP(caps, can_get_monitor_info);
PRINT_CAP(caps, can_pop_frame);
PRINT_CAP(caps, can_redefine_classes);
PRINT_CAP(caps, can_signal_thread);
PRINT_CAP(caps, can_get_source_file_name);
PRINT_CAP(caps, can_get_line_numbers);
PRINT_CAP(caps, can_get_source_debug_extension);
PRINT_CAP(caps, can_access_local_variables);
PRINT_CAP(caps, can_maintain_original_method_order);
PRINT_CAP(caps, can_generate_single_step_events);
PRINT_CAP(caps, can_generate_exception_events);
PRINT_CAP(caps, can_generate_frame_pop_events);
PRINT_CAP(caps, can_generate_breakpoint_events);
PRINT_CAP(caps, can_suspend);
/* :1 */
PRINT_CAP(caps, can_get_current_thread_cpu_time);
PRINT_CAP(caps, can_get_thread_cpu_time);
PRINT_CAP(caps, can_generate_method_entry_events);
PRINT_CAP(caps, can_generate_method_exit_events);
PRINT_CAP(caps, can_generate_all_class_hook_events);
PRINT_CAP(caps, can_generate_compiled_method_load_events);
PRINT_CAP(caps, can_generate_monitor_events);
PRINT_CAP(caps, can_generate_vm_object_alloc_events);
PRINT_CAP(caps, can_generate_native_method_bind_events);
PRINT_CAP(caps, can_generate_garbage_collection_events);
PRINT_CAP(caps, can_generate_object_free_events);
/* :15 */
/* :16 */
/* :16 */
/* :16 */
/* :16 */
/* :16 */
}
#define CHECK_CAP(initCaps, caps, name) \
if (initCaps->name != caps->name) { \
success = NSK_FALSE; \
NSK_COMPLAIN4("GetCapabilities() in %s returned after adding empty capabilities list:" \
"# capability: %s\n" \
"# got value: %d\n" \
"# expected: %d\n", \
where, #name, (int)caps->name, initCaps->name); \
}
/**
* Check value of known capabilities.
* @returns NSK_FALSE if any error occured.
*/
static int checkCapabilitiesValue(jvmtiCapabilities* caps, jvmtiCapabilities* initCaps, const char where[]) {
int success = NSK_TRUE;
CHECK_CAP(initCaps, caps, can_tag_objects);
CHECK_CAP(initCaps, caps, can_generate_field_modification_events);
CHECK_CAP(initCaps, caps, can_generate_field_access_events);
CHECK_CAP(initCaps, caps, can_get_bytecodes);
CHECK_CAP(initCaps, caps, can_get_synthetic_attribute);
CHECK_CAP(initCaps, caps, can_get_owned_monitor_info);
CHECK_CAP(initCaps, caps, can_get_current_contended_monitor);
CHECK_CAP(initCaps, caps, can_get_monitor_info);
CHECK_CAP(initCaps, caps, can_pop_frame);
CHECK_CAP(initCaps, caps, can_redefine_classes);
CHECK_CAP(initCaps, caps, can_signal_thread);
CHECK_CAP(initCaps, caps, can_get_source_file_name);
CHECK_CAP(initCaps, caps, can_get_line_numbers);
CHECK_CAP(initCaps, caps, can_get_source_debug_extension);
CHECK_CAP(initCaps, caps, can_access_local_variables);
CHECK_CAP(initCaps, caps, can_maintain_original_method_order);
CHECK_CAP(initCaps, caps, can_generate_single_step_events);
CHECK_CAP(initCaps, caps, can_generate_exception_events);
CHECK_CAP(initCaps, caps, can_generate_frame_pop_events);
CHECK_CAP(initCaps, caps, can_generate_breakpoint_events);
CHECK_CAP(initCaps, caps, can_suspend);
/* :1 */
CHECK_CAP(initCaps, caps, can_get_current_thread_cpu_time);
CHECK_CAP(initCaps, caps, can_get_thread_cpu_time);
CHECK_CAP(initCaps, caps, can_generate_method_entry_events);
CHECK_CAP(initCaps, caps, can_generate_method_exit_events);
CHECK_CAP(initCaps, caps, can_generate_all_class_hook_events);
CHECK_CAP(initCaps, caps, can_generate_compiled_method_load_events);
CHECK_CAP(initCaps, caps, can_generate_monitor_events);
CHECK_CAP(initCaps, caps, can_generate_vm_object_alloc_events);
CHECK_CAP(initCaps, caps, can_generate_native_method_bind_events);
CHECK_CAP(initCaps, caps, can_generate_garbage_collection_events);
CHECK_CAP(initCaps, caps, can_generate_object_free_events);
/* :15 */
/* :16 */
/* :16 */
/* :16 */
/* :16 */
/* :16 */
return success;
}
/**
* Get and check current capabilities.
* @returns NSK_FALSE if any error occured.
*/
static int checkCapabilities(jvmtiEnv* jvmti, jvmtiCapabilities* initCaps, const char where[]) {
int success = NSK_TRUE;
jvmtiCapabilities caps;
memset(&caps, 0, sizeof(jvmtiCapabilities));
NSK_DISPLAY0("GetCapabilities() for current JVMTI env\n");
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB2(GetCapabilities, jvmti, &caps))) {
return NSK_FALSE;
}
NSK_DISPLAY0("Got raw capabilities:\n");
printRawCapabilities(&caps);
NSK_DISPLAY0("Known capabilities:\n");
printKnownCapabilities(&caps);
NSK_DISPLAY0("Checking capabilities value:\n");
success = checkCapabilitiesValue(&caps, initCaps, where);
NSK_DISPLAY0(" ... checked\n");
return success;
}
/**
* Add given capabilities list.
* @returns NSK_FALSE if any error occured.
*/
static int addCapabilities(jvmtiEnv* jvmti, jvmtiCapabilities* caps, const char where[]) {
NSK_DISPLAY0("AddCapabilities() for current JVMTI env\n");
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB2(AddCapabilities, jvmti, caps))) {
return NSK_FALSE;
}
NSK_DISPLAY0(" ... set\n");
return NSK_TRUE;
}
/* ============================================================================= */
/** Agent algorithm. */
static void JNICALL
agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
NSK_DISPLAY0("Wait for debugee to become ready\n");
if (!nsk_jvmti_waitForSync(timeout))
return;
NSK_DISPLAY0(">>> Testcase #3: Check capabilities in agent thread\n");
if (!checkCapabilities(jvmti, &initCaps, "agent thread")) {
nsk_jvmti_setFailStatus();
}
NSK_DISPLAY0("Let debugee to finish\n");
if (!nsk_jvmti_resumeSync())
return;
}
/* ============================================================================= */
/**
* Callback for VM_INIT event.
*/
JNIEXPORT void JNICALL
callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
NSK_DISPLAY0(">>> Testcase #2: Check capabilities in VM_INIT callback\n");
if (!checkCapabilities(jvmti, &initCaps, "VM_INIT callback")) {
nsk_jvmti_setFailStatus();
}
}
/**
* Callback for VM_DEATH event.
*/
JNIEXPORT void JNICALL
callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) {
int success = NSK_TRUE;
NSK_DISPLAY0(">>> Testcase #4: Check capabilities in VM_DEATH callback\n");
success = checkCapabilities(jvmti, &initCaps, "VM_DEATH callback");
NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT);
if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) {
success = NSK_FALSE;
} else {
NSK_DISPLAY0(" ... disabled\n");
}
if (!success) {
NSK_DISPLAY1("Exit with FAIL exit status: %d\n", STATUS_FAIL);
NSK_BEFORE_TRACE(exit(STATUS_FAIL));
}
}
/* ============================================================================= */
/** Agent library initialization. */
#ifdef STATIC_BUILD
JNIEXPORT jint JNICALL Agent_OnLoad_addcaps001(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNICALL Agent_OnAttach_addcaps001(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNI_OnLoad_addcaps001(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiEnv* jvmti = NULL;
if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
return JNI_ERR;
timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
if (!NSK_VERIFY((jvmti =
nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
return JNI_ERR;
{
jvmtiEventCallbacks eventCallbacks;
memset(&eventCallbacks, 0, sizeof(eventCallbacks));
eventCallbacks.VMInit = callbackVMInit;
eventCallbacks.VMDeath = callbackVMDeath;
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB3(SetEventCallbacks, jvmti,
&eventCallbacks, sizeof(eventCallbacks)))) {
return JNI_ERR;
}
}
if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
return JNI_ERR;
NSK_DISPLAY0(">>> Testcase #0: Add empty capabilities list in Agent_OnLoad()\n");
memset(&initCaps, 0, sizeof(jvmtiCapabilities));
if (!addCapabilities(jvmti, &initCaps, "Agent_OnLoad()")) {
nsk_jvmti_setFailStatus();
}
NSK_DISPLAY0(">>> Testcase #1: Check capabilities in Agent_OnLoad()\n");
if (!checkCapabilities(jvmti, &initCaps, "Agent_OnLoad()")) {
nsk_jvmti_setFailStatus();
}
NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT);
if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) {
NSK_DISPLAY0(" ... enabled\n");
}
return JNI_OK;
}
/* ============================================================================= */
#ifdef __cplusplus
}
#endif

@ -0,0 +1,33 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "agent_common.c"
#include "addcaps001.c"

@ -0,0 +1,71 @@
/*
* Copyright (c) 2003, 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.jvmti.AddCapabilities;
import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
public class addcaps002 extends DebugeeClass {
// load native library if required
static {
System.loadLibrary("addcaps002");
}
// run test from command line
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
// run test from JCK-compatible environment
public static int run(String argv[], PrintStream out) {
return new addcaps002().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
ArgumentHandler argHandler = null;
Log log = null;
long timeout = 0;
int status = Consts.TEST_PASSED;
// run debuggee
public int runIt(String argv[], PrintStream out) {
argHandler = new ArgumentHandler(argv);
log = new Log(out, argHandler);
timeout = argHandler.getWaitTime() * 60 * 1000; // milliseconds
// testing sync
log.display("Sync: debugee ready");
status = checkStatus(status);
return status;
}
}

@ -0,0 +1,59 @@
/*
* 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/jvmti/AddCapabilities/addcaps002.
* VM Testbase keywords: [quick, jpda, jvmti, noras]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function GetCapabilities().
* This test checks that AddCapabilities() successfully adds all capabilities
* returned by GetPotentialCapabilities() in Agent_OnLoad().
* This is checked by GetCapabilities either on OnLoad and live phases.
* In verbose mode the test prints obtained capabilities either as raw bits
* and as values of known capabilities.
* The following checks are performed for AddCapabilities():
* - in JVM_OnLoad() on OnLoad phase
* The following checks are performed for GetCapabilities():
* - in JVM_OnLoad() on OnLoad phase
* - in VM_INIT event on live phase
* - in agent thread on live phase
* - in VM_DEATH callback on live phase
* The test passes if AddCapabilities() returns no error code and
* GetCapabilities() returns the same capabilities list as was ovbtained
* by GetPotentialCapabilities() in all checks.
* If the last check (in VM_DEATH callback) fails, then C-language exit()
* function is used to force VM exit with fail status 97.
* COMMENTS
* Modified due to fix of the rfe
* 5010823 TEST_RFE: some JVMTI tests use the replaced capability
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/native -agentlib:addcaps002=-waittime=5 nsk.jvmti.AddCapabilities.addcaps002
*/

@ -0,0 +1,377 @@
/*
* Copyright (c) 2003, 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.
*/
#include <stdlib.h>
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "jni_tools.h"
#include "jvmti_tools.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================================= */
static jlong timeout = 0;
#define STATUS_FAIL 97
#define EVENTS_COUNT 2
static jvmtiEvent events[EVENTS_COUNT] = {
JVMTI_EVENT_VM_INIT,
JVMTI_EVENT_VM_DEATH
};
static jvmtiCapabilities initCaps;
/* ============================================================================= */
/** Prints capabilities structure as raw bits. */
static void printRawCapabilities(const jvmtiCapabilities* caps) {
const unsigned char* p = (const unsigned char*)caps;
int size = (int) sizeof(jvmtiCapabilities);
int i, j, k;
nsk_printf(" ");
for (j = 0; j < 16; j++) {
nsk_printf(" %1X", j);
}
nsk_printf("\n");
for (i = 0; i < size; i += 2) {
int prefix = i / 2;
nsk_printf(" 0x%03X.: ", prefix);
for (k = 0; k < 2; k++) {
unsigned char b = *(p++);
for (j = 0; j < 8; j++) {
int bit = b % 2;
b /= 2;
nsk_printf(" %1d", bit);
}
}
nsk_printf("\n");
}
}
#define PRINT_CAP(caps, name) nsk_printf(" %-40s: %d\n", #name, (int)caps->name)
/** Print values of known capabilities. */
static void printKnownCapabilities(const jvmtiCapabilities* caps) {
PRINT_CAP(caps, can_tag_objects);
PRINT_CAP(caps, can_generate_field_modification_events);
PRINT_CAP(caps, can_generate_field_access_events);
PRINT_CAP(caps, can_get_bytecodes);
PRINT_CAP(caps, can_get_synthetic_attribute);
PRINT_CAP(caps, can_get_owned_monitor_info);
PRINT_CAP(caps, can_get_current_contended_monitor);
PRINT_CAP(caps, can_get_monitor_info);
PRINT_CAP(caps, can_pop_frame);
PRINT_CAP(caps, can_redefine_classes);
PRINT_CAP(caps, can_signal_thread);
PRINT_CAP(caps, can_get_source_file_name);
PRINT_CAP(caps, can_get_line_numbers);
PRINT_CAP(caps, can_get_source_debug_extension);
PRINT_CAP(caps, can_access_local_variables);
PRINT_CAP(caps, can_maintain_original_method_order);
PRINT_CAP(caps, can_generate_single_step_events);
PRINT_CAP(caps, can_generate_exception_events);
PRINT_CAP(caps, can_generate_frame_pop_events);
PRINT_CAP(caps, can_generate_breakpoint_events);
PRINT_CAP(caps, can_suspend);
/* :1 */
PRINT_CAP(caps, can_get_current_thread_cpu_time);
PRINT_CAP(caps, can_get_thread_cpu_time);
PRINT_CAP(caps, can_generate_method_entry_events);
PRINT_CAP(caps, can_generate_method_exit_events);
PRINT_CAP(caps, can_generate_all_class_hook_events);
PRINT_CAP(caps, can_generate_compiled_method_load_events);
PRINT_CAP(caps, can_generate_monitor_events);
PRINT_CAP(caps, can_generate_vm_object_alloc_events);
PRINT_CAP(caps, can_generate_native_method_bind_events);
PRINT_CAP(caps, can_generate_garbage_collection_events);
PRINT_CAP(caps, can_generate_object_free_events);
/* :15 */
/* :16 */
/* :16 */
/* :16 */
/* :16 */
/* :16 */
}
#define CHECK_CAP(initCaps, caps, name) \
if (initCaps->name != caps->name) { \
success = NSK_FALSE; \
NSK_COMPLAIN4("GetCapabilities() in %s returned after adding all potential capabilities:" \
"# capability: %s\n" \
"# got value: %d\n" \
"# expected: %d\n", \
where, #name, (int)caps->name, initCaps->name); \
}
/**
* Check value of known capabilities.
* @returns NSK_FALSE if any error occured.
*/
static int checkCapabilitiesValue(jvmtiCapabilities* caps, jvmtiCapabilities* initCaps, const char where[]) {
int success = NSK_TRUE;
CHECK_CAP(initCaps, caps, can_tag_objects);
CHECK_CAP(initCaps, caps, can_generate_field_modification_events);
CHECK_CAP(initCaps, caps, can_generate_field_access_events);
CHECK_CAP(initCaps, caps, can_get_bytecodes);
CHECK_CAP(initCaps, caps, can_get_synthetic_attribute);
CHECK_CAP(initCaps, caps, can_get_owned_monitor_info);
CHECK_CAP(initCaps, caps, can_get_current_contended_monitor);
CHECK_CAP(initCaps, caps, can_get_monitor_info);
CHECK_CAP(initCaps, caps, can_pop_frame);
CHECK_CAP(initCaps, caps, can_redefine_classes);
CHECK_CAP(initCaps, caps, can_signal_thread);
CHECK_CAP(initCaps, caps, can_get_source_file_name);
CHECK_CAP(initCaps, caps, can_get_line_numbers);
CHECK_CAP(initCaps, caps, can_get_source_debug_extension);
CHECK_CAP(initCaps, caps, can_access_local_variables);
CHECK_CAP(initCaps, caps, can_maintain_original_method_order);
CHECK_CAP(initCaps, caps, can_generate_single_step_events);
CHECK_CAP(initCaps, caps, can_generate_exception_events);
CHECK_CAP(initCaps, caps, can_generate_frame_pop_events);
CHECK_CAP(initCaps, caps, can_generate_breakpoint_events);
CHECK_CAP(initCaps, caps, can_suspend);
/* :1 */
CHECK_CAP(initCaps, caps, can_get_current_thread_cpu_time);
CHECK_CAP(initCaps, caps, can_get_thread_cpu_time);
CHECK_CAP(initCaps, caps, can_generate_method_entry_events);
CHECK_CAP(initCaps, caps, can_generate_method_exit_events);
CHECK_CAP(initCaps, caps, can_generate_all_class_hook_events);
CHECK_CAP(initCaps, caps, can_generate_compiled_method_load_events);
CHECK_CAP(initCaps, caps, can_generate_monitor_events);
CHECK_CAP(initCaps, caps, can_generate_vm_object_alloc_events);
CHECK_CAP(initCaps, caps, can_generate_native_method_bind_events);
CHECK_CAP(initCaps, caps, can_generate_garbage_collection_events);
CHECK_CAP(initCaps, caps, can_generate_object_free_events);
/* :15 */
/* :16 */
/* :16 */
/* :16 */
/* :16 */
/* :16 */
return success;
}
/**
* Get and check current capabilities.
* @returns NSK_FALSE if any error occured.
*/
static int checkCapabilities(jvmtiEnv* jvmti, jvmtiCapabilities* initCaps, const char where[]) {
int success = NSK_TRUE;
jvmtiCapabilities caps;
memset(&caps, 0, sizeof(jvmtiCapabilities));
NSK_DISPLAY0("GetCapabilities() for current JVMTI env\n");
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB2(GetCapabilities, jvmti, &caps))) {
return NSK_FALSE;
}
NSK_DISPLAY0("Got raw capabilities:\n");
printRawCapabilities(&caps);
NSK_DISPLAY0("Known capabilities:\n");
printKnownCapabilities(&caps);
NSK_DISPLAY0("Checking capabilities value:\n");
success = checkCapabilitiesValue(&caps, initCaps, where);
NSK_DISPLAY0(" ... checked\n");
return success;
}
/**
* Add given capabilities list.
* @returns NSK_FALSE if any error occured.
*/
static int addCapabilities(jvmtiEnv* jvmti, jvmtiCapabilities* caps, const char where[]) {
NSK_DISPLAY0("AddCapabilities() for current JVMTI env\n");
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB2(AddCapabilities, jvmti, caps))) {
return NSK_FALSE;
}
NSK_DISPLAY0(" ... set\n");
return NSK_TRUE;
}
/**
* Get potential capabilities to the given list.
* @returns NSK_FALSE if any error occured.
*/
static int getPotentialCapabilities(jvmtiEnv* jvmti, jvmtiCapabilities* caps) {
NSK_DISPLAY0("GetPotentialCapabilities() for current JVMTI env\n");
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB2(GetPotentialCapabilities, jvmti, caps))) {
return NSK_FALSE;
}
NSK_DISPLAY0("Got raw capabilities:\n");
printRawCapabilities(caps);
NSK_DISPLAY0("Known capabilities:\n");
printKnownCapabilities(caps);
return NSK_TRUE;
}
/* ============================================================================= */
/** Agent algorithm. */
static void JNICALL
agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
NSK_DISPLAY0("Wait for debugee to become ready\n");
if (!nsk_jvmti_waitForSync(timeout))
return;
NSK_DISPLAY0(">>> Testcase #3: Check capabilities in agent thread\n");
if (!checkCapabilities(jvmti, &initCaps, "agent thread")) {
nsk_jvmti_setFailStatus();
}
NSK_DISPLAY0("Let debugee to finish\n");
if (!nsk_jvmti_resumeSync())
return;
}
/* ============================================================================= */
/**
* Callback for VM_INIT event.
*/
JNIEXPORT void JNICALL
callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
NSK_DISPLAY0(">>> Testcase #2: Check capabilities in VM_INIT callback\n");
if (!checkCapabilities(jvmti, &initCaps, "VM_INIT callback")) {
nsk_jvmti_setFailStatus();
}
}
/**
* Callback for VM_DEATH event.
*/
JNIEXPORT void JNICALL
callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) {
int success = NSK_TRUE;
NSK_DISPLAY0(">>> Testcase #4: Check capabilities in VM_DEATH callback\n");
success = checkCapabilities(jvmti, &initCaps, "VM_DEATH callback");
NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT);
if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) {
success = NSK_FALSE;
} else {
NSK_DISPLAY0(" ... disabled\n");
}
if (!success) {
NSK_DISPLAY1("Exit with FAIL exit status: %d\n", STATUS_FAIL);
NSK_BEFORE_TRACE(exit(STATUS_FAIL));
}
}
/* ============================================================================= */
/** Agent library initialization. */
#ifdef STATIC_BUILD
JNIEXPORT jint JNICALL Agent_OnLoad_addcaps002(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNICALL Agent_OnAttach_addcaps002(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNI_OnLoad_addcaps002(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiEnv* jvmti = NULL;
if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
return JNI_ERR;
timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
if (!NSK_VERIFY((jvmti =
nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
return JNI_ERR;
{
jvmtiEventCallbacks eventCallbacks;
memset(&eventCallbacks, 0, sizeof(eventCallbacks));
eventCallbacks.VMInit = callbackVMInit;
eventCallbacks.VMDeath = callbackVMDeath;
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB3(SetEventCallbacks, jvmti,
&eventCallbacks, sizeof(eventCallbacks)))) {
return JNI_ERR;
}
}
if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
return JNI_ERR;
memset(&initCaps, 0, sizeof(jvmtiCapabilities));
if (!getPotentialCapabilities(jvmti, &initCaps)) {
return JNI_ERR;
}
NSK_DISPLAY0(">>> Testcase #0: Add all potential capabilities in Agent_OnLoad()\n");
if (!addCapabilities(jvmti, &initCaps, "Agent_OnLoad()")) {
nsk_jvmti_setFailStatus();
}
NSK_DISPLAY0(">>> Testcase #1: Check capabilities in Agent_OnLoad()\n");
if (!checkCapabilities(jvmti, &initCaps, "Agent_OnLoad()")) {
nsk_jvmti_setFailStatus();
}
NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT);
if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) {
NSK_DISPLAY0(" ... enabled\n");
}
return JNI_OK;
}
/* ============================================================================= */
#ifdef __cplusplus
}
#endif

@ -0,0 +1,33 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "agent_common.c"
#include "addcaps002.c"

@ -0,0 +1,70 @@
/*
* Copyright (c) 2007, 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.jvmti.AddCapabilities;
import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
public class addcaps003 extends DebugeeClass {
// load native library if required
static {
System.loadLibrary("addcaps003");
}
// run test from command line
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
// run test from JCK-compatible environment
public static int run(String argv[], PrintStream out) {
return new addcaps003().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
ArgumentHandler argHandler = null;
Log log = null;
long timeout = 0;
int status = Consts.TEST_PASSED;
// run debuggee
public int runIt(String argv[], PrintStream out) {
argHandler = new ArgumentHandler(argv);
log = new Log(out, argHandler);
timeout = argHandler.getWaitTime() * 60 * 1000; // milliseconds
// testing sync
log.display("Sync: debugee ready");
status = checkStatus(status);
return status;
}
}

@ -0,0 +1,61 @@
/*
* 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/jvmti/AddCapabilities/addcaps003.
* VM Testbase keywords: [quick, jpda, jvmti, noras, vm6]
* VM Testbase readme:
* DESCRIPTION
* Bug ID: 6316807
* This JVMTI test exercises JVMTI GetCapabilities() function with the following flags:
* -XX:+PrintInterpreter -XX:+TaggedStackInterpreter
* The bug's evaluation field says:
* "The interpreter allocates a fixed size buffer in order to generate code
* for itself. Product code can fail in the interpreter with the
* guarantee("not enough space for interpreter generation");
* when this code space is not sufficient. New code has been added to the
* interpreter for TaggedStackInterpreter and for JVMTI which can increase the
* size needed by the interpreter code buffer. The interpreter code size is
* hardcoded and it's not typical for people to change the size when one
* adds new code to the interpreter, so it can run out. Also the intepreter
* code size in NOT_PRODUCT is multiplied by 4 so the code size doesn't typically
* run out in debug mode, which is the mode we test."
* COMMENTS
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build ExecDriver
* nsk.jvmti.AddCapabilities.addcaps003
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* -XX:+UnlockDiagnosticVMOptions
* -XX:+PrintInterpreter
* -XX:+IgnoreUnrecognizedVMOptions
* -XX:+TaggedStackInterpreter
* -agentlib:addcaps003=-waittime=5
* nsk.jvmti.AddCapabilities.addcaps003
*/

@ -0,0 +1,226 @@
/*
* Copyright (c) 2007, 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.
*/
#include <stdlib.h>
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "jni_tools.h"
#include "jvmti_tools.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================================= */
static jlong timeout = 0;
#define STATUS_FAIL 97
#define EVENTS_COUNT 2
static jvmtiEvent events[EVENTS_COUNT] = {
JVMTI_EVENT_VM_INIT,
JVMTI_EVENT_VM_DEATH
};
static jvmtiCapabilities initCaps;
/* ============================================================================= */
/**
* Get and check current capabilities.
* @returns NSK_FALSE if any error occured.
*/
static int checkCapabilities(jvmtiEnv* jvmti, jvmtiCapabilities* initCaps, const char where[]) {
int success = NSK_TRUE;
jvmtiCapabilities caps;
memset(&caps, 0, sizeof(jvmtiCapabilities));
NSK_DISPLAY0("GetCapabilities() for current JVMTI env\n");
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB2(GetCapabilities, jvmti, &caps))) {
return NSK_FALSE;
}
return success;
}
/**
* Add given capabilities list.
* @returns NSK_FALSE if any error occured.
*/
static int addCapabilities(jvmtiEnv* jvmti, jvmtiCapabilities* caps, const char where[]) {
NSK_DISPLAY0("AddCapabilities() for current JVMTI env\n");
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB2(AddCapabilities, jvmti, caps))) {
return NSK_FALSE;
}
NSK_DISPLAY0(" ... set\n");
return NSK_TRUE;
}
/**
* Get potential capabilities to the given list.
* @returns NSK_FALSE if any error occured.
*/
static int getPotentialCapabilities(jvmtiEnv* jvmti, jvmtiCapabilities* caps) {
NSK_DISPLAY0("GetPotentialCapabilities() for current JVMTI env\n");
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB2(GetPotentialCapabilities, jvmti, caps))) {
return NSK_FALSE;
}
return NSK_TRUE;
}
/* ============================================================================= */
/** Agent algorithm. */
static void JNICALL
agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
NSK_DISPLAY0("Wait for debugee to become ready\n");
if (!nsk_jvmti_waitForSync(timeout))
return;
NSK_DISPLAY0(">>> Testcase #3: Check capabilities in agent thread\n");
if (!checkCapabilities(jvmti, &initCaps, "agent thread")) {
nsk_jvmti_setFailStatus();
}
NSK_DISPLAY0("Let debugee to finish\n");
if (!nsk_jvmti_resumeSync())
return;
}
/* ============================================================================= */
/**
* Callback for VM_INIT event.
*/
JNIEXPORT void JNICALL
callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
NSK_DISPLAY0(">>> Testcase #2: Check capabilities in VM_INIT callback\n");
if (!checkCapabilities(jvmti, &initCaps, "VM_INIT callback")) {
nsk_jvmti_setFailStatus();
}
}
/**
* Callback for VM_DEATH event.
*/
JNIEXPORT void JNICALL
callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) {
int success = NSK_TRUE;
NSK_DISPLAY0(">>> Testcase #4: Check capabilities in VM_DEATH callback\n");
success = checkCapabilities(jvmti, &initCaps, "VM_DEATH callback");
NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT);
if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) {
success = NSK_FALSE;
} else {
NSK_DISPLAY0(" ... disabled\n");
}
if (!success) {
NSK_DISPLAY1("Exit with FAIL exit status: %d\n", STATUS_FAIL);
NSK_BEFORE_TRACE(exit(STATUS_FAIL));
}
}
/* ============================================================================= */
/** Agent library initialization. */
#ifdef STATIC_BUILD
JNIEXPORT jint JNICALL Agent_OnLoad_addcaps003(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNICALL Agent_OnAttach_addcaps003(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNI_OnLoad_addcaps003(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiEnv* jvmti = NULL;
if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
return JNI_ERR;
timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
if (!NSK_VERIFY((jvmti =
nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
return JNI_ERR;
{
jvmtiEventCallbacks eventCallbacks;
memset(&eventCallbacks, 0, sizeof(eventCallbacks));
eventCallbacks.VMInit = callbackVMInit;
eventCallbacks.VMDeath = callbackVMDeath;
if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB3(SetEventCallbacks, jvmti,
&eventCallbacks, sizeof(eventCallbacks)))) {
return JNI_ERR;
}
}
if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
return JNI_ERR;
memset(&initCaps, 0, sizeof(jvmtiCapabilities));
if (!getPotentialCapabilities(jvmti, &initCaps)) {
return JNI_ERR;
}
NSK_DISPLAY0(">>> Testcase #0: Add all potential capabilities in Agent_OnLoad()\n");
if (!addCapabilities(jvmti, &initCaps, "Agent_OnLoad()")) {
nsk_jvmti_setFailStatus();
}
NSK_DISPLAY0(">>> Testcase #1: Check capabilities in Agent_OnLoad()\n");
if (!checkCapabilities(jvmti, &initCaps, "Agent_OnLoad()")) {
nsk_jvmti_setFailStatus();
}
NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT);
if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) {
NSK_DISPLAY0(" ... enabled\n");
}
return JNI_OK;
}
/* ============================================================================= */
#ifdef __cplusplus
}
#endif

@ -0,0 +1,33 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "agent_common.c"
#include "addcaps003.c"

@ -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/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch001.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, no_cds]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch().
* This test checks that AddToBootstrapClassLoaderSearch() adds segment
* to bootstrap class search path in OnLoad phase and bootstrap classloader
* will find debuggee class using that segment.
* Debuggee class does not have direct superclass to be loaded too.
* The following checks are performed by the test:
* - AddToBootstrapClassLoaderSearch() returns no errors in OnLoad phase
* - debuggee class will be found by bootstrap classloader using added segment
* Source of debuggee class 'bootclssearch001' is located in special subdirectory
* 'newclass' and thus will be compiled to '$COMMON_CLASSES_LOCATION/newclass'
* subdirectory, where it usually can not be found by bootstrap classloader.
* The agent adds this subdirectory to the bootstrap class search path
* in Agent_OnLoad(), and thus the debuggee class should be found by
* bootstrap classloader and executed normally.
* If AddToBootstrapClassLoaderSearch() returns error in Agent_OnLoad(),
* then agent returns JNI_ERR and VM fails on initialization.
* If AddToBootstrapClassLoaderSearch() does not adds segment to bootstrap
* class search path, then debuggee class is not found and VM fails on
* initialization.
* Otherwise, if debuggee class is found, loaded, executed, it returns PASS
* and the test passes with exit code 95.
* COMMENTS
* Made code cleanup: nsk/share/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch_agent
* agent is used now.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.Consts
*
* @comment compile newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* newclass
*
* @build ExecDriver
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* "-agentlib:bootclssearch_agent=-waittime=5 phasetocheck=onload segment1=./bin/newclass"
* nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch001
*/

@ -0,0 +1,54 @@
/*
* Copyright (c) 2003, 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.jvmti.AddToBootstrapClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.Consts;
/** Debuggee class for this test. */
public class bootclssearch001 {
/** Run test from command line. */
public static void main(String argv[]) {
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new bootclssearch001().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("Debuggee executed");
return status;
}
}

@ -0,0 +1,98 @@
/*
* 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/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch002.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, no_cds]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch().
* This test checks that AddToBootstrapClassLoaderSearch() adds segment
* to bootstrap class search path and bootstrap classloader will find
* debuggee class using that segment.
* Debuggee class has direct superclass located in the original bootstrap classpath.
* The following checks are performed by the test:
* - AddToBootstrapClassLoaderSearch() returns no errors in OnLoad phase
* - debuggee class will be found by bootstrap classloader using added segment
* - superclass needed for debuggee class will be also found by bootstrap
* classloader though located in the original bootstrap classpath
* - superclass needed for debuggee class will be loaded from bootstrap
* classpath, not from usual classpath
* Source of debuggee class 'bootclssearch002' is located in subdirectory 'newclass'.
* It will be compiled to '$COMMON_CLASSES_LOCATION/newclass', where it usually
* cannot be found by bootstrap classloader.
* The superclass 'bootclssearch002p' has two different implementations.
* Source of "positive" implementation is located in subdirectory 'loadclass'.
* It will be compiled to '$COMMON_CLASSES_LOCATION/loadclass' that is added
* to original bootstrap classpath using option -Xbootclasspath/a.
* This implementation returns PASS.
* Source of "negative" implementation is located in the currect directory.
* It will be compiled to '$COMMON_CLASSES_LOCATION/classes' that is available
* from usual classpath.
* This implementation prints error and returns FAIL.
* The agent adds '$COMMON_CLASSES_LOCATION/newclass' directory with debuggee
* class implementation to the bootstrap class search path in Agent_OnLoad(),
* and thus the debuggee class should be found by bootstrap classloader.
* While loading debuggee class the bootstrap classloader should find and load
* "positive" implementation of superclass available from original bootstrap
* classpath, but not "negative" implementation available from usual classpath.
* If AddToBootstrapClassLoaderSearch() returns error in Agent_OnLoad(),
* then agent returns JNI_ERR and VM fails on initialization.
* If AddToBootstrapClassLoaderSearch() does not adds segment to bootstrap
* classloader search path, then debuggee class is not found and VM
* fails on initialization.
* If bootstrap classloader cannot find superclass located by the original
* bootstrap classpath, then VM also fails on initialization.
* If bootstrap classloader loads "negative" implementation of superclass
* available from usual classpath, then the debuggee class returns FAIL,
* and the test fails with exit code 97.
* Otherwise, if segment is successfully added and debuggee class with positive
* implementation of superclass are found, loaded, and executed, then it
* returns PASS. and the test passes with exit code 95.
* COMMENTS
* Made code cleanup: nsk/share/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch_agent
* agent is used now.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch002p
*
* @comment compile loadclassXX to bin/loadclassXX
* @run driver nsk.share.ExtraClassesBuilder
* loadclass
*
* @comment compile newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* newclass
*
* @build ExecDriver
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* -Xbootclasspath/a:./bin/loadclass
* "-agentlib:bootclssearch_agent=-waittime=5 phasetocheck=onload segment1=./bin/newclass"
* nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch002
*/

@ -0,0 +1,40 @@
/*
* Copyright (c) 2003, 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.jvmti.AddToBootstrapClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.Consts;
/** Positive superclass for debuggee class. */
public class bootclssearch002p {
// scaffold objects
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("Positive implementation of superclass was found and loaded");
return status;
}
}

@ -0,0 +1,43 @@
/*
* Copyright (c) 2003, 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.jvmti.AddToBootstrapClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.Consts;
/** Debuggee class for this test. */
public class bootclssearch002 extends bootclssearch002p {
/** Run test from command line. */
public static void main(String argv[]) {
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new bootclssearch002().runIt(argv, out);
}
}

@ -0,0 +1,43 @@
/*
* Copyright (c) 2003, 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.jvmti.AddToBootstrapClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
/** Negative superclass for debuggee class. */
public class bootclssearch002p {
// scaffold objects
int status = Consts.TEST_FAILED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("ERROR: Debuggee class was loaded from segment added with AddToBootstrapClassSearchPath(),");
out.println("ERROR: but its superclass was loaded from usual classpath, not from bootstrap classpath,");
out.println("ERROR: added with option +Xbootclasspath/a");
return status;
}
}

@ -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/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch003.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, no_cds]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch().
* This test checks that AddToBootstrapClassLoaderSearch() adds segment
* to bootstrap class search path in OnLoad phase, but debuggee class
* located by this segment will no be loaded if this class is available
* from the original bootstrap classpath.
* The following checks are performed by the test:
* - AddToBootstrapClassLoaderSearch() returns no errors in OnLoad phase
* - debuggee class located by the original bootstrap classpath will be loaded
* - debuggee class located by the added segment will NOT be loaded
* There are two different impelmentations of debuggee class 'bootclssearch003'.
* Source of "positive" implementation is located in subdirectory 'loadclass'.
* It will be compiled to '$COMMON_CLASSES_LOCATION/loadclass' and added to
* original bootstrap classpath using option +Xbootclasspath/a.
* This implementation returns PASS status.
* Source of "negative" implementation is located in subdirectory 'newclass'.
* It will be compiled to '$COMMON_CLASSES_LOCATION/newclass' and added
* to bootstrap class search path with AddToBootstrapClassLoaderSearch().
* This implementation returns prints error and returns FAIL status.
* The agent adds subdirectory '$COMMON_CLASSES_LOCATION/newclass' to
* the bootstrap classloader search path in Agent_OnLoad(), and expects
* that positive implementation of debuggee class will be loaded and
* executed.
* If AddToBootstrapClassLoaderSearch() returns error in Agent_OnLoad(),
* then agent returns JNI_ERR and VM fails on initialization.
* If negative version of debuggee class will be loaded and executed,
* then it returns FAIL and test fails with exit code 97.
* Otherwise, if positive version of debuggee class will be loaded and executed,
* then it returns PASS and test passes with exit code 95.
* COMMENTS
* Made code cleanup: nsk/share/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch_agent
* agent is used now.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.Consts
*
* @comment compile loadclassXX to bin/loadclassXX
* @run driver nsk.share.ExtraClassesBuilder
* loadclass
*
* @comment compile newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* newclass
*
* @build ExecDriver
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* -Xbootclasspath/a:./bin/loadclass
* "-agentlib:bootclssearch_agent=-waittime=5 phasetocheck=onload segment1=./bin/newclass"
* nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch003
*/

@ -0,0 +1,54 @@
/*
* Copyright (c) 2003, 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.jvmti.AddToBootstrapClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.Consts;
/** Debuggee class for this test. */
public class bootclssearch003 {
/** Run test from command line. */
public static void main(String argv[]) {
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new bootclssearch003().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("Positive debuggee class executed");
return status;
}
}

@ -0,0 +1,55 @@
/*
* Copyright (c) 2003, 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.jvmti.AddToBootstrapClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.Consts;
/** Debuggee class for this test. */
public class bootclssearch003 {
/** Run test from command line. */
public static void main(String argv[]) {
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new bootclssearch003().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
int status = Consts.TEST_FAILED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("# ERROR: Class was loaded from directory added by AddToBootstrapClassLoaderSearch()");
out.println("# ERROR: though this class is also available from usual class search path");
return status;
}
}

@ -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/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch004.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, no_cds]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch().
* This test checks that AddToBootstrapClassLoaderSearch() can add two segments
* to bootstrap class search path in OnLoad phase, and debuggee class will be
* loaded from the first segment even if it is found in the second segment too,
* The following checks are performed by the test:
* - AddToBootstrapClassLoaderSearch() adds two segments and returns
* no errors in OnLoad phase
* - debuggee class located by the first added segment will be loaded
* - debuggee class located by the second added segment will NOT be loaded
* There are two different implementations of debuggee class 'bootclssearch004'.
* Source of "positive" implementation is located in subdirectory 'newclass01'.
* It will be compiled to '$COMMON_CLASSES_LOCATION/newclass01', that will be
* added first to bootstrap class search path.
* This implementation returns PASS.
* Source of "negative" implementation is located in subdirectory 'newclass02'.
* It will be compiled to '$COMMON_CLASSES_LOCATION/newclass02', that will be
* added second to bootstrap class search path.
* This implementation returns FAIL.
* The agent adds both subdirectories to the bootstrap class search path
* in Agent_OnLoad(), and expects that positive implementation of debuggee class
* from the first added segment will be loaded and executed.
* If AddToBootstrapClassLoaderSearch() returns error in Agent_OnLoad(),
* then agent returns JNI_ERR and VM fails on initialization.
* If negative implementation of debuggee class is loaded and executed,
* then it returns FAIL and test fails with exit code 97.
* Otherwise, if both segments are successfully added and positive implementation
* of debuggee class is loaded and executed, then it returns PASS and test
* passes with exit code 95.
* COMMENTS
* Made code cleanup: nsk/share/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch_agent
* agent is used now.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.Consts
*
* @comment compile newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* newclass02 newclass01
*
* @build ExecDriver
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* "-agentlib:bootclssearch_agent=-waittime=5 phasetocheck=onload segment1=./bin/newclass01 segment2=./bin/newclass02"
* nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch004
*/

@ -0,0 +1,54 @@
/*
* Copyright (c) 2003, 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.jvmti.AddToBootstrapClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.Consts;
/** Debuggee class for this test. */
public class bootclssearch004 {
/** Run test from command line. */
public static void main(String argv[]) {
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new bootclssearch004().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("Positive debuggee class executed");
return status;
}
}

@ -0,0 +1,57 @@
/*
* Copyright (c) 2003, 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.jvmti.AddToBootstrapClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.Consts;
/** Debuggee class for this test. */
public class bootclssearch004 {
/** Run test from command line. */
public static void main(String argv[]) {
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new bootclssearch004().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
int status = Consts.TEST_FAILED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("# ERROR: This class was actually loaded from directory added by");
out.println("# ERROR: first call to AddToBootstrapClassLoaderSearch(),");
out.println("# ERROR: though this class is also available from durectory added by");
out.println("# ERROR: second call to AddToBootstrapClassLoaderSearch(),");
return status;
}
}

@ -0,0 +1,93 @@
/*
* 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/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch007.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6, no_cds]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch()
* in Live phase.
* This test checks that AddToBootstrapClassLoaderSearch() adds segment
* to bootstrap class search path in Live phase, but debuggee class
* located by this segment will no be loaded if this class is available
* from the original bootstrap classpath.
* The following checks are performed by the test:
* - AddToBootstrapClassLoaderSearch() returns no errors in Live phase
* - in particular it checks that anything other than an
* existing JAR file is an invalid path
* - debuggee class located by the original bootstrap classpath will be loaded
* - debuggee class located by the added segment will NOT be loaded
* There are two different impelmentations of debuggee class 'bootclssearch003'.
* Source of "positive" implementation is located in subdirectory 'loadclass'.
* It will be compiled to '$COMMON_CLASSES_LOCATION/loadclass' and added to
* original bootstrap classpath using option -Xbootclasspath/a.
* This implementation returns PASS status.
* Source of "negative" implementation is located in 'bootclssearch003.jar'
* which is located in subdirectory 'newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/'.
* It will be compiled to
* '$COMMON_CLASSES_LOCATION/newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch003.jar'
* and added to bootstrap class search path with AddToBootstrapClassLoaderSearch().
* This implementation returns prints error and returns FAIL status.
* The agent adds jar file
* '$COMMON_CLASSES_LOCATION/newclassnsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch003.jar'
* to the bootstrap classloader search path in VM_INIT callback, and expects
* that positive implementation of debuggee class will be loaded and
* executed.
* If negative version of debuggee class will be loaded and executed,
* then it returns FAIL and test fails with exit code 97.
* Otherwise, if positive version of debuggee class will be loaded and executed,
* then it returns PASS and test passes with exit code 95.
* COMMENTS
* Ported from bootclssearch003.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.Consts
*
* @comment compile ../bootclssearch003/loadclassXX to bin/loadclassXX
* @run driver nsk.share.ExtraClassesBuilder
* ../bootclssearch003/loadclass
*
* @comment compile ../bootclssearch003/newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* ../bootclssearch003/newclass
*
* @comment create bootclssearch003.jar in current directory
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cf bootclssearch003.jar
* -C ./bin/newclass/
* nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch003.class
*
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* -Xbootclasspath/a:./bin/loadclass
* "-agentlib:bootclssearch_agent=-waittime=5 phasetocheck=live segment1=./bootclssearch003.jar"
* nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch003
*/

@ -0,0 +1,100 @@
/*
* 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/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch008.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6, no_cds]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch()
* in Live phase (actually only in VM_INIT callback).
* This test checks that AddToBootstrapClassLoaderSearch() can add two segments
* to bootstrap class search path in Live phase, and debuggee class will be
* loaded from the first segment even if it is found in the second segment too,
* The following checks are performed by the test:
* - AddToBootstrapClassLoaderSearch() adds two segments and returns
* no errors in Live phase
* - also it checks that anything other than an
* existing JAR file is an invalid path
* - debuggee class located by the first added segment will be loaded
* - debuggee class located by the second added segment will NOT be loaded
* There are two different implementations of debuggee class 'bootclssearch004'.
* Source of "positive" implementation is located in jar file 'bootclssearch004.jar'
* which is located in subdirectory 'newclass01/nsk/jvmti/AddToBootstrapClassLoaderSearch/'.
* It will be compiled to
* '$COMMON_CLASSES_LOCATION/newclass01/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch004.jar',
* that will be added first to bootstrap class search path.
* This implementation returns PASS.
* Source of "negative" implementation is located in jar file 'bootclssearch004.jar'
* which is located in subdirectory 'newclass02/nsk/jvmti/AddToBootstrapClassLoaderSearch/'.
* It will be compiled to
* '$COMMON_CLASSES_LOCATION/newclass02/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch004.jar',
* that will be added second to bootstrap class search path.
* This implementation returns FAIL.
* The agent adds both jars to the bootstrap class search path
* in VM_INIT callback, and expects that positive implementation of debuggee class
* from the first added segment will be loaded and executed.
* If AddToBootstrapClassLoaderSearch() returns error in VM_INIT callback,
* then VM fails on initialization.
* If negative implementation of debuggee class is loaded and executed,
* then it returns FAIL and test fails with exit code 97.
* Otherwise, if both segments are successfully added and positive implementation
* of debuggee class is loaded and executed, then it returns PASS and test
* passes with exit code 95.
* COMMENTS
* Ported from bootclssearch004.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.Consts
*
* @comment compile ../bootclssearch004/newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* ../bootclssearch004/newclass01
* ../bootclssearch004/newclass02
*
* @comment create bootclssearch004.jar in ./bin/newclass01/
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cf ./bin/newclass01/bootclssearch004.jar
* -C ./bin/newclass01/
* nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch004.class
*
* @comment create bootclssearch004.jar in ./bin/newclass02/
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cf ./bin/newclass02/bootclssearch004.jar
* -C ./bin/newclass02/
* nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch004.class
*
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* "-agentlib:bootclssearch_agent=-waittime=5 phasetocheck=live segment1=./bin/newclass01/bootclssearch004.jar segment2=./bin/newclass02/bootclssearch004.jar"
* nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch004
*/

@ -0,0 +1,80 @@
/*
* 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/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch009.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6, no_cds]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch()
* in Live phase.
* This test checks that AddToBootstrapClassLoaderSearch() adds segment
* to bootstrap class search path in Live phase and bootstrap classloader
* will find debuggee class using that segment.
* Debuggee class does not have direct superclass to be loaded too.
* The following checks are performed by the test:
* - AddToBootstrapClassLoaderSearch() returns no errors in Live phase
* - in particular it checks that anything other than an
* existing JAR file is an invalid path
* - debuggee class will be found by bootstrap classloader using added segment
* Source of debuggee class 'bootclssearch001' is located in 'bootclssearch001.jar'
* which is located in special subdirectory 'newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/'.
* It will be compiled to
* '$COMMON_CLASSES_LOCATION/newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch001.jar'
* jar file, where it usually can not be found by bootstrap classloader.
* The agent adds this jar to the bootstrap class search path
* in VM_INIT callback(), and thus the debuggee class should be found by
* bootstrap classloader and executed normally.
* If AddToBootstrapClassLoaderSearch() does not adds segment to bootstrap
* class search path, then debuggee class is not found and VM fails on
* initialization.
* Otherwise, if debuggee class is found, loaded, executed, it returns PASS
* and the test passes with exit code 95.
* COMMENTS
* Ported from bootclssearch001.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.Consts
*
* @comment compile ../bootclssearch001/newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* ../bootclssearch001/newclass
*
* @comment create bootclssearch001.jar in current directory
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cf bootclssearch001.jar
* -C ./bin/newclass/
* nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch001.class
*
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* "-agentlib:bootclssearch_agent=-waittime=5 phasetocheck=live segment1=./bootclssearch001.jar"
* nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch001
*/

@ -0,0 +1,109 @@
/*
* 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/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch010.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6, no_cds]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch()
* in Live phase.
* This test checks that AddToBootstrapClassLoaderSearch() adds segment
* to bootstrap class search path and bootstrap classloader will find
* debuggee class using that segment.
* Debuggee class has direct superclass located in the original bootstrap classpath.
* The following checks are performed by the test:
* - AddToBootstrapClassLoaderSearch() returns no errors in Live phase
* - in particular it checks that anything other than an
* existing JAR file is an invalid path
* - debuggee class will be found by bootstrap classloader using added segment
* - superclass needed for debuggee class will be also found by bootstrap
* classloader though located in the original bootstrap classpath
* - superclass needed for debuggee class will be loaded from bootstrap
* classpath, not from usual classpath
* Source of debuggee class 'bootclssearch002' is located in 'bootclssearch002.jar'
* which is located in subdirectory 'newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/'.
* It will be compiled to
* '$COMMON_CLASSES_LOCATION/newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch002.jar'
* jar file where it usually cannot be found by bootstrap classloader.
* The superclass 'bootclssearch002p' has two different implementations.
* Source of "positive" implementation is located in subdirectory 'loadclass'.
* It will be compiled to '$COMMON_CLASSES_LOCATION/loadclass' that is added
* to original bootstrap classpath using option -Xbootclasspath/a.
* This implementation returns PASS.
* Source of "negative" implementation is located in the currect directory.
* It will be compiled to '$COMMON_CLASSES_LOCATION/classes' that is available
* from usual classpath.
* This implementation prints error and returns FAIL.
* The agent adds
* '$COMMON_CLASSES_LOCATION/newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch002.jar'
* jar file with debuggee
* class implementation to the bootstrap class search path in VM_INIT callback,
* and thus the debuggee class should be found by bootstrap classloader.
* While loading debuggee class the bootstrap classloader should find and load
* "positive" implementation of superclass available from original bootstrap
* classpath, but not "negative" implementation available from usual classpath.
* If AddToBootstrapClassLoaderSearch() does not adds segment to bootstrap
* classloader search path, then debuggee class is not found and VM
* fails on initialization.
* If bootstrap classloader cannot find superclass located by the original
* bootstrap classpath, then VM also fails on initialization.
* If bootstrap classloader loads "negative" implementation of superclass
* available from usual classpath, then the debuggee class returns FAIL,
* and the test fails with exit code 97.
* Otherwise, if segment is successfully added and debuggee class with positive
* implementation of superclass are found, loaded, and executed, then it
* returns PASS. and the test passes with exit code 95.
* COMMENTS
* Ported from bootclssearch002.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch002p
*
* @comment compile ../bootclssearch002/loadclassXX to bin/loadclassXX
* @run driver nsk.share.ExtraClassesBuilder
* ../bootclssearch002/loadclass
*
* @comment compile ../bootclssearch002/newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* ../bootclssearch002/newclass
*
* @comment create bootclssearch002.jar in current directory
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cf bootclssearch002.jar
* -C ./bin/newclass/
* nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch002.class
*
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* -Xbootclasspath/a:./bin/loadclass
* "-agentlib:bootclssearch_agent=-waittime=5 phasetocheck=live segment1=./bootclssearch002.jar"
* nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch002
*/

@ -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/jvmti/AddToSystemClassLoaderSearch/systemclssearch001.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToSystemClassLoaderSearch()
* in OnLoad phase.
* This test checks that AddToSystemClassLoaderSearch() adds segment
* to system class search path in OnLoad phase and system classloader
* will find debuggee class using that segment.
* Debuggee class does not have direct superclass to be loaded too.
* The following checks are performed by the test:
* - AddToSystemClassLoaderSearch() returns no errors in OnLoad phase
* - debuggee class will be found by system classloader using added segment
* Source of debuggee class 'systemclssearch001' is located in special subdirectory
* 'newclass' and thus will be compiled to '$COMMON_CLASSES_LOCATION/newclass'
* subdirectory, where it usually can not be found by system classloader.
* The agent adds this subdirectory to the system class search path
* in Agent_OnLoad(), and thus the debuggee class should be found by
* system classloader and executed normally.
* If AddToSystemClassLoaderSearch() returns error in Agent_OnLoad(),
* then agent returns JNI_ERR and VM fails on initialization.
* If AddToSystemClassLoaderSearch() does not adds segment to system
* class search path, then debuggee class is not found and VM fails on
* initialization.
* Otherwise, if debuggee class is found, loaded, executed, it returns PASS
* and the test passes with exit code 95.
* COMMENTS
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.jvmti.JVMTITest
* nsk.share.Consts
*
* @comment compile newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* newclass
*
* @build ExecDriver
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* -cp ${test.class.path}${path.separator}./bin/newclass
* "-agentlib:systemclssearch_agent=-waittime=5 phasetocheck=onload segment1=./bin/newclass"
* nsk.jvmti.AddToSystemClassLoaderSearch.systemclssearch001
*/

@ -0,0 +1,56 @@
/*
* Copyright (c) 2007, 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.jvmti.AddToSystemClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.Consts;
/** Debuggee class for this test. */
public class systemclssearch001 {
/** Run test from command line. */
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new systemclssearch001().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("Debuggee executed");
return status;
}
}

@ -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/jvmti/AddToSystemClassLoaderSearch/systemclssearch002.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToSystemClassLoaderSearch()
* in OnLoad phase.
* This test checks that AddToSystemClassLoaderSearch() adds segment
* to system class search path and system classloader will find
* debuggee class using that segment while loading debugge supper class
* from original classpath.
* The following checks are performed by the test:
* - AddToSystemClassLoaderSearch() returns no errors in OnLoad phase
* - debuggee class will be loaded from system
* classpath using added segment
* - superclass needed for debuggee class will be found by system
* classloader using original classpath
* Source of debuggee class 'systemclssearch002' is located in special subdirectory
* 'newclass' and thus will be compiled to '$COMMON_CLASSES_LOCATION/newclass'
* subdirectory, where it usually can not be found by system classloader.
* If AddToSystemClassLoaderSearch() returns error in Agent_OnLoad(),
* then agent returns JNI_ERR and VM fails on initialization.
* If AddToSystemClassLoaderSearch() does not adds segment to system
* classloader search path, then debuggee class is not found and VM
* fails on initialization.
* If segment is successfully added and debuggee super class are found, loaded, and executed,
* then it returns PASS. and the test passes with exit code 95.
* COMMENTS
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.jvmti.AddToSystemClassLoaderSearch.systemclssearch002p
* nsk.share.jvmti.JVMTITest
*
* @comment compile newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* newclass
*
* @build ExecDriver
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* "-agentlib:systemclssearch_agent=-waittime=5 phasetocheck=onload segment1=./bin/newclass"
* nsk.jvmti.AddToSystemClassLoaderSearch.systemclssearch002
*/

@ -0,0 +1,45 @@
/*
* Copyright (c) 2007, 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.jvmti.AddToSystemClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.*;
/** Debuggee class for this test. */
public class systemclssearch002 extends systemclssearch002p {
/** Run test from command line. */
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new systemclssearch002().runIt(argv, out);
}
}

@ -0,0 +1,41 @@
/*
* Copyright (c) 2007, 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.jvmti.AddToSystemClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
/** Positive superclass for debuggee class. */
public class systemclssearch002p {
// scaffold objects
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("Positive implementation of superclass was found and loaded");
return status;
}
}

@ -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/jvmti/AddToSystemClassLoaderSearch/systemclssearch003.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToSystemClassLoaderSearch()
* in OnLoad phase.
* This test checks that AddToSystemClassLoaderSearch() can add two segments
* to system class search path in OnLoad phase, and debuggee class will be
* loaded from the first segment even if it is found in the second segment too,
* The following checks are performed by the test:
* - AddToSystemClassLoaderSearch() adds two segments and returns
* no errors in OnLoad phase
* - debuggee class located by the first added segment will be loaded
* - debuggee class located by the second added segment will NOT be loaded
* There are two different implementations of debuggee class 'systemclssearch003'.
* Source of "positive" implementation is located in subdirectory 'newclass01'.
* It will be compiled to '$COMMON_CLASSES_LOCATION/newclass01', that will be
* added first to system class search path.
* This implementation returns PASS.
* Source of "negative" implementation is located in subdirectory 'newclass02'.
* It will be compiled to '$COMMON_CLASSES_LOCATION/newclass02', that will be
* added second to system class search path.
* This implementation returns FAIL.
* The agent adds both subdirectories to the system class search path
* in Agent_OnLoad(), and expects that positive implementation of debuggee class
* from the first added segment will be loaded and executed.
* If AddToSystemClassLoaderSearch() returns error in Agent_OnLoad(),
* then agent returns JNI_ERR and VM fails on initialization.
* If negative implementation of debuggee class is loaded and executed,
* then it returns FAIL and test fails with exit code 97.
* Otherwise, if both segments are successfully added and positive implementation
* of debuggee class is loaded and executed, then it returns PASS and test
* passes with exit code 95.
* COMMENTS
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.jvmti.JVMTITest
* nsk.share.Consts
*
* @comment compile newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* newclass02 newclass01
*
* @build ExecDriver
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* "-agentlib:systemclssearch_agent=-waittime=5 phasetocheck=onload segment1=./bin/newclass01 segment2=./bin/newclass02"
* nsk.jvmti.AddToSystemClassLoaderSearch.systemclssearch003
*/

@ -0,0 +1,56 @@
/*
* Copyright (c) 2007, 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.jvmti.AddToSystemClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.*;
/** Debuggee class for this test. */
public class systemclssearch003 {
/** Run test from command line. */
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new systemclssearch003().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("Positive debuggee class executed");
return status;
}
}

@ -0,0 +1,60 @@
/*
* Copyright (c) 2007, 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.jvmti.AddToSystemClassLoaderSearch;
import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
/** Debuggee class for this test. */
public class systemclssearch003 {
/** Run test from command line. */
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new systemclssearch003().runIt(argv, out);
}
/* =================================================================== */
// scaffold objects
int status = Consts.TEST_FAILED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
out.println("# ERROR: This class was actually loaded from directory added by");
out.println("# ERROR: first call to AddToSystemClassLoaderSearch(),");
out.println("# ERROR: though this class is also available from durectory added by");
out.println("# ERROR: second call to AddToSystemClassLoaderSearch(),");
return status;
}
}

@ -0,0 +1,100 @@
/*
* 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/jvmti/AddToSystemClassLoaderSearch/systemclssearch004.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToSystemClassLoaderSearch()
* in Live phase.
* This test checks that AddToSystemClassLoaderSearch() can add two segments
* to system class search path in Live phase, and debuggee class will be
* loaded from the first segment even if it is found in the second segment too,
* The following checks are performed by the test:
* - AddToSystemClassLoaderSearch() adds two segments and returns
* no errors in Live phase
* - also it checks that anything other than an
* existing JAR file is an invalid path
* - debuggee class located by the first added segment will be loaded
* - debuggee class located by the second added segment will NOT be loaded
* Source of "positive" implementation is located in jar file 'systemclssearch003.jar'
* which is located in subdirectory 'newclass01/nsk/jvmti/AddToSystemClassLoaderSearch/'.
* It will be compiled to
* '$COMMON_CLASSES_LOCATION/newclass01/nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch003.jar',
* that will be added first to system class search path.
* This implementation returns PASS.
* Source of "negative" implementation is located in jar file 'systemclssearch003.jar'
* which is located in subdirectory 'newclass02/nsk/jvmti/AddToSystemClassLoaderSearch/'.
* It will be compiled to
* '$COMMON_CLASSES_LOCATION/newclass02/nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch003.jar',
* that will be added second to system class search path.
* This implementation returns FAIL.
* The agent adds both jars to the system class search path
* in VM_INIT callback, and expects that positive implementation of debuggee class
* from the first added segment will be loaded and executed.
* If AddToSystemClassLoaderSearch() returns error in VM_INIT callback,
* then VM fails on initialization.
* If negative implementation of debuggee class is loaded and executed,
* then it returns FAIL and test fails with exit code 97.
* Otherwise, if both segments are successfully added and positive implementation
* of debuggee class is loaded and executed, then it returns PASS and test
* passes with exit code 95.
* COMMENTS
* Ported from systemclssearch003.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.jvmti.JVMTITest
* nsk.share.Consts
*
* @comment compile ../systemclssearch003/newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* ../systemclssearch003/newclass01
* ../systemclssearch003/newclass02
*
* @comment create systemclssearch003.jar in current directory
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cf ./bin/newclass01/systemclssearch003.jar
* -C ./bin/newclass01/
* nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch003.class
*
* @comment create systemclssearch003.jar in current directory
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cf ./bin/newclass02/systemclssearch003.jar
* -C ./bin/newclass02/
* nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch003.class
*
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* "-agentlib:systemclssearch_agent=-waittime=5 phasetocheck=live segment1=./bin/newclass01/systemclssearch003.jar segment2=./bin/newclass02/systemclssearch003.jar"
* nsk.jvmti.AddToSystemClassLoaderSearch.systemclssearch003
*/

@ -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/jvmti/AddToSystemClassLoaderSearch/systemclssearch005.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToSystemClassLoaderSearch()
* in Live phase.
* This test checks that AddToSystemClassLoaderSearch() adds segment
* to system class search path in Live phase and system classloader
* will find debuggee class using that segment.
* Debuggee class does not have direct superclass to be loaded too.
* The following checks are performed by the test:
* - AddToSystemClassLoaderSearch() returns no errors in Live phase
* - in particular it checks that anything other than an
* existing JAR file is an invalid path
* - debuggee class will be found by system classloader using added segment
* Source of debuggee class 'systemclssearch001' is located in 'systemclssearch001.jar'
* which is located in special subdirectory 'newclass/nsk/jvmti/AddToSystemClassLoaderSearch/'.
* It will be compiled to
* '$COMMON_CLASSES_LOCATION/newclass/nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch001.jar'
* jar file, where it usually can not be found by system classloader.
* The agent adds this jar to the system class search path
* in VM_INIT callback(), and thus the debuggee class should be found by
* system classloader and executed normally.
* If AddToSystemClassLoaderSearch() does not adds segment to system
* class search path, then debuggee class is not found and VM fails on
* initialization.
* Otherwise, if debuggee class is found, loaded, executed, it returns PASS
* and the test passes with exit code 95.
* COMMENTS
* Ported from systemclssearch001.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.jvmti.JVMTITest
* nsk.share.Consts
*
* @comment compile ../systemclssearch001/newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* ../systemclssearch001/newclass
*
* @comment create systemclssearch001.jar in current directory
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cf systemclssearch001.jar
* -C ./bin/newclass/
* nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch001.class
*
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* "-agentlib:systemclssearch_agent=-waittime=5 phasetocheck=live segment1=systemclssearch001.jar"
* nsk.jvmti.AddToSystemClassLoaderSearch.systemclssearch001
*/

@ -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/jvmti/AddToSystemClassLoaderSearch/systemclssearch006.
* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function AddToSystemClassLoaderSearch()
* in Live phase.
* This test checks that AddToSystemClassLoaderSearch() adds segment
* to system class search path and system classloader will find
* debuggee class using that segment while loading debugge supper class
* from original classpath.
* The following checks are performed by the test:
* - AddToSystemClassLoaderSearch() returns no errors in OnLoad phase
* - debuggee class will be loaded from system
* classpath using added segment
* - superclass needed for debuggee class will be found by system
* classloader using original classpath
* Source of debuggee class 'systemclssearch002' is located in 'systemclssearch002.jar'
* which is located in subdirectory 'newclass/nsk/jvmti/AddToSystemClassLoaderSearch/'.
* It will be compiled to
* '$COMMON_CLASSES_LOCATION/newclass/nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch002.jar'
* jar file where it usually cannot be found by system classloader.
* If AddToSystemClassLoaderSearch() does not adds segment to system
* classloader search path, then debuggee class is not found and VM
* fails on initialization.
* If system classloader cannot find superclass located by the original
* system classpath, then VM also fails on initialization.
* If segment is successfully added and debuggee super class are found, loaded, and executed,
* then it returns PASS. and the test passes with exit code 95.
* COMMENTS
* Ported from systemclssearch002.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.jvmti.AddToSystemClassLoaderSearch.systemclssearch002p
* nsk.share.jvmti.JVMTITest
*
* @comment compile ../systemclssearch002/newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* ../systemclssearch002/newclass
*
* @comment create systemclssearch002.jar in current directory
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cf systemclssearch002.jar
* -C ./bin/newclass/
* nsk/jvmti/AddToSystemClassLoaderSearch/systemclssearch002.class
*
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* "-agentlib:systemclssearch_agent=-waittime=5 phasetocheck=live segment1=systemclssearch002.jar"
* nsk.jvmti.AddToSystemClassLoaderSearch.systemclssearch002
*/

@ -0,0 +1,72 @@
/*
* Copyright (c) 2003, 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.jvmti.Agent_OnLoad;
import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
public class agentonload001 extends DebugeeClass {
/** Load native library if required. */
static {
loadLibrary("agentonload001");
}
/** Run test from command line. */
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new agentonload001().runIt(argv, out);
}
/* =================================================================== */
/* scaffold objects */
ArgumentHandler argHandler = null;
Log log = null;
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
argHandler = new ArgumentHandler(argv);
log = new Log(out, argHandler);
status = checkLoadStatus();
if (status != Consts.TEST_PASSED) {
log.complain("Agent_Onload() was not invoked on startup");
}
return status;
}
/** Check JVM_OnLoad status in native code. */
private native int checkLoadStatus();
}

@ -0,0 +1,53 @@
/*
* 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/jvmti/Agent_OnLoad/agentonload001.
* VM Testbase keywords: [quick, jpda, jvmti, noras]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function Agent_OnLoad().
* This test checks that Agent_OnLoad() is invoked on startup,
* and not NULL values are passed for 'vm' and 'options' parameters.
* This test does not create JVMTI environment.
* The test uses native method checkLoadStatus() to check value of internal
* native variable 'status' set by JVM_OnLoad().
* If JVM_OnLoad() was not invoked on startup, then checkLoadStatus()
* returns FAILED and test fails with exit status 97.
* If JVM_OnLoad() was invoked but NULL values were passed for any
* of 'vm' or 'options' parameters, then JVM_OnLoad() returns with
* JNI_ERR and the test fails with exit status 1,
* Otherwise, the test passes with exit status 95.
* COMMENTS
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/native
* -agentlib:agentonload001=-waittime=5
* nsk.jvmti.Agent_OnLoad.agentonload001
*/

@ -0,0 +1,93 @@
/*
* Copyright (c) 2003, 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.
*/
#include "jvmti.h"
#include "agent_common.h"
#include "jvmti_tools.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================================= */
#define STATUS_FAILED 2
#define PASSED 0
static volatile int status = STATUS_FAILED;
/* ============================================================================= */
/** Check status of JVM_OnLoad() invocation. */
JNIEXPORT jint JNICALL
Java_nsk_jvmti_Agent_1OnLoad_agentonload001_checkLoadStatus(JNIEnv* jni, jobject obj) {
return status;
}
/* ============================================================================= */
/** Agent library initialization. */
#ifdef STATIC_BUILD
JNIEXPORT jint JNICALL Agent_OnLoad_agentonload001(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNICALL Agent_OnAttach_agentonload001(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNI_OnLoad_agentonload001(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
status = PASSED;
if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
return JNI_ERR;
NSK_DISPLAY0("JVM_OnLoad is invoked with parameters:\n");
NSK_DISPLAY1(" vm: 0x%p\n", (void*)jvm);
NSK_DISPLAY1(" options: \"%s\"\n", nsk_null_string(options));
NSK_DISPLAY1(" reserved: 0x%p\n", (void*)jvm);
if (jvm == NULL) {
NSK_COMPLAIN1("First parameter 'vm' in JVM_OnLoad() is NULL: 0x%p\n", (void*)jvm);
status = STATUS_FAILED;
}
if (options == NULL) {
NSK_COMPLAIN1("Second parameter 'options' in JVM_OnLoad() is NULL: 0x%p\n", (void*)options);
status = STATUS_FAILED;
}
if (status != PASSED) {
return JNI_ERR;
}
return JNI_OK;
}
/* ============================================================================= */
#ifdef __cplusplus
}
#endif

@ -0,0 +1,33 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "agent_common.c"
#include "agentonload001.c"

@ -0,0 +1,54 @@
/*
* Copyright (c) 2003, 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.jvmti.Agent_OnLoad;
import java.io.PrintStream;
import nsk.share.*;
public class agentonload002 {
/** Run test from command line. */
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new agentonload002().runIt(argv, out);
}
/* =================================================================== */
/* scaffold objects */
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
return status;
}
}

@ -0,0 +1,48 @@
/*
* 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/jvmti/Agent_OnLoad/agentonload002.
* VM Testbase keywords: [quick, jpda, jvmti, noras]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function Agent_OnLoad().
* This test checks that options string passed to Agent_OnLoad() is
* identical to specified in command line, event if it is empty.
* The test does not create JVMTI environment, neither use JVMTI framework.
* If options string passed to AgentOnLoad() is NULL or not empty,
* then Agent_OnLoad() returns with JNI_ERR and test fails with
* exit status 1.
* Otherwise, the test executes trivial debuggee class and passes
* with exit status 95.
* COMMENTS
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/native -agentlib:agentonload002= nsk.jvmti.Agent_OnLoad.agentonload002
*/

@ -0,0 +1,74 @@
/*
* Copyright (c) 2003, 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.
*/
#include <stdio.h>
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================================= */
#define TESTED_OPTIONS ""
/* ============================================================================= */
/** Agent library initialization. */
#ifdef STATIC_BUILD
JNIEXPORT jint JNICALL Agent_OnLoad_agentonload002(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNICALL Agent_OnAttach_agentonload002(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNI_OnLoad_agentonload002(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
if (options == NULL) {
printf("# ERROR: Second parameter 'options' in JVM_OnLoad() is NULL: 0x%p\n",
(void*)options);
return JNI_ERR;
}
if (strcmp(options, TESTED_OPTIONS) != 0) {
printf("# ERROR: Unexpected options string passed to JVM_OnLoad():\n"
"# got string: \"%s\"\n"
"# expected: \"%s\"\n",
options, TESTED_OPTIONS);
return JNI_ERR;
}
return JNI_OK;
}
/* ============================================================================= */
#ifdef __cplusplus
}
#endif

@ -0,0 +1,33 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "agent_common.c"
#include "agentonload002.c"

@ -0,0 +1,54 @@
/*
* Copyright (c) 2003, 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.jvmti.Agent_OnLoad;
import java.io.PrintStream;
import nsk.share.*;
public class agentonload003 {
/** Run test from command line. */
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new agentonload003().runIt(argv, out);
}
/* =================================================================== */
/* scaffold objects */
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
return status;
}
}

@ -0,0 +1,59 @@
/*
* 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/jvmti/Agent_OnLoad/agentonload003.
* VM Testbase keywords: [quick, jpda, jvmti, noras]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function Agent_OnLoad().
* This test checks that options string passed to Agent_OnLoad() is
* identical to specified in command line, event if it contains blanks.
* The test does not create JVMTI environment, neither use JVMTI framework.
* If options string passed to AgentOnLoad() is not equal to expected,
* then Agent_OnLoad() returns with JNI_ERR and test fails with
* exit status 1.
* Otherwise, the test executes trivial debuggee class and passes
* with exit status 95.
* COMMENTS
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/native TestDriver
*/
import java.io.IOException;
public class TestDriver {
public static void main(String[] args) throws IOException, InterruptedException {
// TestDriver is needed b/c jtreg replaces \s\s* w/ \s
ExecDriver.main(new String[] {
"--java",
"-agentlib:agentonload003=options string with blanks",
nsk.jvmti.Agent_OnLoad.agentonload003.class.getName()});
}
}

@ -0,0 +1,74 @@
/*
* Copyright (c) 2003, 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.
*/
#include <stdio.h>
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================================= */
#define TESTED_OPTIONS "options string with blanks"
/* ============================================================================= */
/** Agent library initialization. */
#ifdef STATIC_BUILD
JNIEXPORT jint JNICALL Agent_OnLoad_agentonload003(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNICALL Agent_OnAttach_agentonload003(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNI_OnLoad_agentonload003(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
if (options == NULL) {
printf("# ERROR: Second parameter 'options' in JVM_OnLoad() is NULL: 0x%p\n",
(void*)options);
return JNI_ERR;
}
if (strcmp(options, TESTED_OPTIONS) != 0) {
printf("# ERROR: Unexpected options string passed to JVM_OnLoad():\n"
"# got string: \"%s\"\n"
"# expected: \"%s\"\n",
options, TESTED_OPTIONS);
return JNI_ERR;
}
return JNI_OK;
}
/* ============================================================================= */
#ifdef __cplusplus
}
#endif

@ -0,0 +1,33 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "agent_common.c"
#include "agentonload003.c"

@ -0,0 +1,72 @@
/*
* Copyright (c) 2003, 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.jvmti.Agent_OnUnload;
import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
public class agentonunload001 extends DebugeeClass {
/** Load native library if required. */
static {
loadLibrary("agentonunload001");
}
/** Run test from command line. */
public static void main(String argv[]) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
// JCK-compatible exit
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
}
/** Run test from JCK-compatible environment. */
public static int run(String argv[], PrintStream out) {
return new agentonunload001().runIt(argv, out);
}
/* =================================================================== */
/* scaffold objects */
ArgumentHandler argHandler = null;
Log log = null;
int status = Consts.TEST_PASSED;
/** Run debuggee code. */
public int runIt(String argv[], PrintStream out) {
argHandler = new ArgumentHandler(argv);
log = new Log(out, argHandler);
status = checkLoadStatus();
if (status != Consts.TEST_PASSED) {
log.complain("Agent_OnUnload() was invoked before debuggee class has finished");
}
return status;
}
/** Check JVM_OnUnload status in native code. */
private native int checkLoadStatus();
}

@ -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/jvmti/Agent_OnUnload/agentonunload001.
* VM Testbase keywords: [quick, jpda, jvmti, noras]
* VM Testbase readme:
* DESCRIPTION
* This JVMTI test exercises JVMTI thread function Agent_OnUnload()().
* This test checks that Agent_OnUnload() is invoked on shutdown,
* after class execution. This test does not create JVMTI environment.
* The test uses native method checkLoadStatus() to check value of
* internal native variable 'status' set by JVM_OnUnload(). Also the test
* uses sh script to check if JVM_OnUnload() was invoked and printed
* key message to stdout stream.
* If JVM_OnUnload() was invoked before class has been executed, then
* checkLoadStatus() returns FAILED and the test fails with exit status 97.
* If JVM_OnUnload was not executed and no key message was printed to
* stdout stream, then test fails with exit status 97.
* Otherwise, the test passes with exit status 95.
* COMMENTS
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/native TestDriver
*/
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
public class TestDriver {
public static void main(String[] args) throws Exception {
OutputAnalyzer oa = ProcessTools.executeTestJvm(
"-agentlib:agentonunload001=-waittime=5",
nsk.jvmti.Agent_OnUnload.agentonunload001.class.getName());
oa.shouldHaveExitValue(95);
oa.stdoutShouldContain("KEY PHRASE: Agent_OnUnload() was invoked");
}
}

@ -0,0 +1,88 @@
/*
* Copyright (c) 2003, 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.
*/
#include "jvmti.h"
#include "agent_common.h"
#include "jvmti_tools.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================================= */
#define STATUS_FAILED 2
#define PASSED 0
#define KEY_PHRASE "KEY PHRASE: Agent_OnUnload() was invoked"
static volatile int status = PASSED;
/* ============================================================================= */
/** Check status of JVM_OnUnload() invocation. */
JNIEXPORT jint JNICALL
Java_nsk_jvmti_Agent_1OnUnload_agentonunload001_checkLoadStatus(JNIEnv* jni, jobject obj) {
return status;
}
/* ============================================================================= */
/** Agent library initialization. */
#ifdef STATIC_BUILD
JNIEXPORT jint JNICALL Agent_OnLoad_agentonunload001(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNICALL Agent_OnAttach_agentonunload001(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNI_OnLoad_agentonunload001(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
return JNI_ERR;
NSK_DISPLAY0("Agent_OnLoad() is successfully invoked\n");
return JNI_OK;
}
/** Agent library shutdown. */
JNIEXPORT void JNICALL
#ifdef STATIC_BUILD
Agent_OnUnload_agentonunload001(JavaVM *jvm)
#else
Agent_OnUnload(JavaVM *jvm)
#endif
{
status = STATUS_FAILED;
fprintf(stdout, "%s\n", KEY_PHRASE);
fflush(stdout);
}
/* ============================================================================= */
#ifdef __cplusplus
}
#endif

@ -0,0 +1,33 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "agent_common.c"
#include "agentonunload001.c"

@ -0,0 +1,72 @@
/*
* Copyright (c) 2003, 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.jvmti.Allocate;
import java.io.PrintStream;
public class alloc001 {
final static int JCK_STATUS_BASE = 95;
static {
try {
System.loadLibrary("alloc001");
} catch (UnsatisfiedLinkError ule) {
System.err.println("Could not load alloc001 library");
System.err.println("java.library.path:"
+ System.getProperty("java.library.path"));
throw ule;
}
}
native static int check();
public static void main(String args[]) {
args = nsk.share.jvmti.JVMTITest.commonInit(args);
// produce JCK-like exit status.
System.exit(run(args, System.out) + JCK_STATUS_BASE);
}
public static int run(String args[], PrintStream out) {
final int ERROR_CODE_NO_OOM = 3; // Error code "FAILED_NO_OOM" defined in alloc001.c
int errorCode = check();
if (errorCode == ERROR_CODE_NO_OOM) {
// The test failed because it did not get the expected OutOfMemory error.
// If we run on mac, that is quite expected since mac often ignores "ulimit -v"
final String os = System.getProperty("os.name").toLowerCase();
out.println("os=" + os);
if (os.indexOf("mac") >= 0 || os.indexOf("windows") >= 0) {
String msg = "Test did not get an OutOfMemory error. " +
"That is not surprising on mac or windows. " +
"Mac usually ignores 'ulimit -v', and windows does not have it. " +
"We consider this test as passed.";
out.println(msg);
errorCode = 0;
}
}
return errorCode;
}
}

@ -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=.

@ -0,0 +1,47 @@
/*
* 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/jvmti/Allocate/alloc001.
* VM Testbase keywords: [jpda, jvmti, noras, nonconcurrent]
* VM Testbase readme:
* DESCRIPTION
* The test exercise JVMTI function Allocate(size, memPtr).
* The test checks the following:
* - if JVMTI_ERROR_NULL_POINTER is returned when memPtr is null
* - if allocated memory is available to access
* - if JVMTI_ERROR_OUT_OF_MEMORY is returned when there is
* insufficient memory available
* COMMENTS
* Ported from JVMDI.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.jvmti.Allocate.alloc001
* @run shell alloc001.sh
*/

@ -0,0 +1,86 @@
#!/bin/bash
# Copyright (c) 2008, 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.
JAVA="$TESTJAVA/bin/java"
JAVA_OPTS="$TESTJAVAOPTS $TESTVMOPTS -cp $TESTCLASSPATH -agentlib:alloc001"
. ${TESTSRC}/../../../../../../../../../open/test/hotspot/jtreg/test_env.sh
# Set virtual memory usage limit to be not 'unlimited' on unix platforms
# This is workaround for 6683371.
case $VM_OS in
aix | bsd | linux | solaris)
echo "Check virtual memory usage limits"
soft_limit=`ulimit -S -v` || ""
hard_limit=`ulimit -H -v` || ""
echo "Virtual memory usage limit (hard): $hard_limit"
echo "Virtual memory usage limit (soft): $soft_limit"
# Need to set ulimit if currently unlimited or > 4GB (1GB on 32 bit)
if [ $VM_BITS -eq 32 ]
then
max_ulimit=1048576
max_heap=256m
else
max_ulimit=4194304
max_heap=512m
fi
should_update_ulimit=0
if [ -n "$soft_limit" ]; then
if [ "$soft_limit" = "unlimited" ]; then
should_update_ulimit=1
elif [ "$soft_limit" -gt "$max_ulimit" ]; then
should_update_ulimit=1
fi
fi
if [ "$should_update_ulimit" = "1" ]; then
echo "Try to limit virtual memory usage to $max_ulimit"
ulimit -S -v $max_ulimit || true
fi
# When we limit virtual memory then we need to also limit other GC args and MALLOC_ARENA_MAX.
# Otherwise the JVM may not start. See JDK-8043516
JAVA_OPTS="${JAVA_OPTS} -XX:MaxHeapSize=$max_heap -XX:CompressedClassSpaceSize=64m"
export MALLOC_ARENA_MAX=4
soft_limit=`ulimit -S -v`
echo "Virtual memory usage limit (soft): $soft_limit"
echo "New JAVA_OPTS: $JAVA_OPTS"
echo "export MALLOC_ARENA_MAX=4"
;;
*)
;;
esac
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$TESTNATIVEPATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TESTNATIVEPATH
export PATH=$PATH:$TESTNATIVEPATH
echo $JAVA ${JAVA_OPTS} nsk.jvmti.Allocate.alloc001
$JAVA ${JAVA_OPTS} nsk.jvmti.Allocate.alloc001
exit=$?
if [ $exit -ne 95 ]
then
exit $exit
fi

@ -0,0 +1,190 @@
/*
* Copyright (c) 2003, 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.
*/
#include <stdio.h>
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "JVMTITools.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef JNI_ENV_ARG
#ifdef __cplusplus
#define JNI_ENV_ARG(x, y) y
#define JNI_ENV_PTR(x) x
#else
#define JNI_ENV_ARG(x,y) x, y
#define JNI_ENV_PTR(x) (*x)
#endif
#endif
#define PASSED 0
#define STATUS_FAILED 2
#define FAILED_NO_OOM 3
#define MAX_CHUNK 1024*1024
// Limit total allocations to 8Gb.
// Without this check we will loop forever if the OS does not
// limit virtual memory (this usually happens on mac).
#define MAX_CHUNK_COUNT 8*1024
static jvmtiEnv *jvmti = NULL;
static jint result = PASSED;
static jboolean printdump = JNI_FALSE;
#ifdef STATIC_BUILD
JNIEXPORT jint JNICALL Agent_OnLoad_alloc001(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNICALL Agent_OnAttach_alloc001(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT jint JNI_OnLoad_alloc001(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jint res;
if (options != NULL && strcmp(options, "printdump") == 0) {
printdump = JNI_TRUE;
}
res = JNI_ENV_PTR(jvm)->
GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1);
if (res != JNI_OK || jvmti == NULL) {
printf("Wrong result of a valid call to GetEnv!\n");
return JNI_ERR;
}
return JNI_OK;
}
JNIEXPORT jint JNICALL
Java_nsk_jvmti_Allocate_alloc001_check(JNIEnv *env, jclass cls) {
jvmtiError err;
size_t size;
void *prev = NULL;
void **mem;
int memCount = 1;
if (jvmti == NULL) {
printf("JVMTI client was not properly loaded!\n");
return STATUS_FAILED;
}
if (printdump == JNI_TRUE) {
printf(">>> Null pointer check ...\n");
}
err = (*jvmti)->Allocate(jvmti, (jlong)1, NULL);
if (err != JVMTI_ERROR_NULL_POINTER) {
printf("Error expected: JVMTI_ERROR_NULL_POINTER, got: %s\n",
TranslateError(err));
result = STATUS_FAILED;
}
if (printdump == JNI_TRUE) {
printf(">>> ... done\n");
}
if (printdump == JNI_TRUE) {
printf(">>> Accessibility check ...\n");
}
for (size = sizeof(mem); size <= MAX_CHUNK; size <<= 1) {
err = (*jvmti)->Allocate(jvmti, size, (unsigned char **)&mem);
if (err == JVMTI_ERROR_NONE) {
memset(mem, 0, size);
*mem = prev;
prev = mem;
} else if (err == JVMTI_ERROR_OUT_OF_MEMORY) {
break;
} else {
printf("(Allocate) Error expected: JVMTI_ERROR_NONE, got: %s\n",
TranslateError(err));
result = STATUS_FAILED;
break;
}
}
if (printdump == JNI_TRUE) {
printf(">>> ... done\n");
}
if (printdump == JNI_TRUE) {
printf(">>> Out of memory check ...\n");
}
while (err != JVMTI_ERROR_OUT_OF_MEMORY) {
err = (*jvmti)->Allocate(jvmti, (jlong)MAX_CHUNK, (unsigned char **)&mem);
if (err == JVMTI_ERROR_NONE) {
*mem = prev;
prev = mem;
memCount++;
if (memCount > MAX_CHUNK_COUNT) {
printf("Allocated %dMb. Virtual memory limit too high. Quit to avoid timeout.\n", memCount);
result = FAILED_NO_OOM;
break;
}
} else if (err == JVMTI_ERROR_OUT_OF_MEMORY) {
break;
} else {
printf("Error expected: JVMTI_ERROR_OUT_OF_MEMORY, got: %s\n",
TranslateError(err));
result = STATUS_FAILED;
break;
}
if (printdump == JNI_TRUE && (memCount % 50 == 0) ) {
printf(">>> ... done (%dMb)\n", memCount);
}
}
if (printdump == JNI_TRUE) {
printf(">>> ... done (%dMb)\n", memCount);
}
if (printdump == JNI_TRUE) {
printf(">>> Deallocation ...\n");
}
while (prev != NULL) {
mem = prev;
prev = *mem;
err = (*jvmti)->Deallocate(jvmti, (unsigned char *)mem);
if (err != JVMTI_ERROR_NONE) {
printf("(Deallocate) Error expected: JVMTI_ERROR_NONE, got: %s\n",
TranslateError(err));
result = STATUS_FAILED;
break;
}
}
if (printdump == JNI_TRUE) {
printf(">>> ... done\n");
}
return result;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,26 @@
#!/bin/sh
# 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.
# as sh's ulimit works weirdly on solaris and jtreg doesn't gurantee what
# shell is used, have to use this file to be sure alloc001.bash is run by bash
bash ./alloc001.bash

@ -0,0 +1,33 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "agent_common.c"
#include "alloc001.c"

@ -0,0 +1,119 @@
/*
* Copyright (c) 2008, 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/jvmti/AttachOnDemand/attach001.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load java and jvmti agents to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework. In the terms of this framework
* java application running in the VM where agent is loaded to is called 'target application'.
* In this test target application tries to attach java and native agents to the same VM where target application
* is running. Test just checks that agents can connect and run (agents don't perform any specific
* checks).
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.jvmti.AttachOnDemand.attach001.attach001TestRunner
*
* @comment create SimpleAgent00.jar in current directory
* @build nsk.jvmti.AttachOnDemand.sharedAgents.SimpleAgent00
* @run driver ClassFileInstaller nsk.jvmti.AttachOnDemand.sharedAgents.SimpleAgent00
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cfm SimpleAgent00.jar ${test.src}/../sharedAgents/SimpleAgent00.mf
* nsk/jvmti/AttachOnDemand/sharedAgents/SimpleAgent00.class
*
* @run main/othervm/native
* -XX:+UsePerfData
* -Djdk.attach.allowAttachSelf
* PropertyResolvingWrapper
* nsk.jvmti.AttachOnDemand.attach001.attach001TestRunner
* -jdk ${test.jdk}
* "-javaOpts=-XX:+UsePerfData -Djdk.attach.allowAttachSelf ${test.vm.opts} ${test.java.opts}"
* -ja SimpleAgent00.jar
* -na simpleAgent00
*/
package nsk.jvmti.AttachOnDemand.attach001;
import nsk.share.Failure;
import nsk.share.aod.*;
import nsk.share.test.TestUtils;
/*
* Test tries to attach agents to the same VM where target application is running
* (test starts target application class in the separate thread instead of separate process).
*/
public class attach001TestRunner extends AODTestRunner {
attach001TestRunner(String[] args) {
super(args);
}
class TargetThread extends Thread {
boolean finishedSuccessfully;
public void run() {
try {
new TargetApplicationWaitingAgents().runTargetApplication(new String[] {
"-" + AODTargetArgParser.agentsNumberParam,
new Integer(argParser.getAgents().size()).toString() });
finishedSuccessfully = true;
} catch (Throwable t) {
log.complain("Unexpected exception: " + t);
t.printStackTrace(log.getOutStream());
}
}
}
protected void runTest() {
try {
TargetThread thread = new TargetThread();
thread.start();
// default test actions - attach agents to the given VM
doTestActions(getCurrentVMId());
thread.join();
if (!thread.finishedSuccessfully) {
TestUtils.testFailed("Unexpected error during test execution (see log for details)");
}
} catch (Failure f) {
throw f;
} catch (Throwable t) {
TestUtils.unexpctedException(t);
}
}
public static void main(String[] args) {
new attach001TestRunner(args).runTest();
}
}

@ -0,0 +1,39 @@
/*
* Copyright (c) 2008, 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.jvmti.AttachOnDemand.attach002;
import java.util.Vector;
public class ClassToRedefine {
public int getSize() {
/*
* in the redefined version size is 10
*/
int size = 100;
Vector<String> vector = new Vector<String>();
for (int i = 0; i < size; i++) {
vector.add("String-" + i);
}
return vector.size();
}
}

@ -0,0 +1,61 @@
/*
* 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/jvmti/AttachOnDemand/attach002.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load jvmti agent to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework. In the terms of this framework
* java application running in the VM where agent is loaded to is called 'target application'.
* Test performs following checks:
* - loaded agent can get capabilities 'generate_all_class_hook_events' and 'can_redefine_classes'
* - agent receives events ClassFileLoadHook, ClassLoad, ClassPepare for the class loaded by the target
* application
* - agent can redefine class loaded by the target application from the ClassLoad event handler and
* agent receives ClassFileLoadHook after class redefinition
* - after class redefinition target application checks that redefinition really had effect
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
*
* @comment compile newclassXX to bin/newclassXX
* @run driver nsk.share.ExtraClassesBuilder
* newclass00
*
* @build nsk.jvmti.AttachOnDemand.attach002.attach002Target
* @run main/othervm/native PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* -target nsk.jvmti.AttachOnDemand.attach002.attach002Target
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
* -na attach002Agent00=-pathToNewByteCode=./bin/newclass00
*/

@ -0,0 +1,246 @@
/*
* Copyright (c) 2007, 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#include <jvmti.h>
#include <aod.h>
#include <jvmti_aod.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Expected agent work scenario:
* - receive ClassFileLoadHook event for class 'ClassToRedefine'
* - receive ClassLoad event for class 'ClassToRedefine' and redefine class from ClassLoad event handler
* - receive one more ClassFileLoadHook event for class 'ClassToRedefine'
* - receive ClassPrepare event for class 'ClassToRedefine' and finish work
*/
#define REDEFINED_CLASS_NAME "Lnsk/jvmti/AttachOnDemand/attach002/ClassToRedefine;"
#define REDEFINED_CLASS_FILE_NAME "nsk/jvmti/AttachOnDemand/attach002/ClassToRedefine"
// class name in the ClassFileLoadHook callback
#define REDEFINED_CLASS_NAME_INTERNAL "nsk/jvmti/AttachOnDemand/attach002/ClassToRedefine"
static Options* options = NULL;
static const char* agentName;
static volatile jboolean agentGotCapabilities = JNI_FALSE;
static jvmtiEvent testEvents[] = {
JVMTI_EVENT_CLASS_LOAD,
JVMTI_EVENT_CLASS_PREPARE,
JVMTI_EVENT_CLASS_FILE_LOAD_HOOK};
static const int testEventsNumber = 3;
static volatile int classLoadReceived = 0;
static volatile int classFileLoadHookReceived = 0;
JNIEXPORT jboolean JNICALL
Java_nsk_jvmti_AttachOnDemand_attach002_attach002Target_agentGotCapabilities(JNIEnv * jni,
jclass klass, jobject obj) {
return agentGotCapabilities;
}
#define ATTACH002_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach002/attach002Target"
int registerNativeMethods(JNIEnv* jni) {
jclass appClass;
JNINativeMethod nativeMethods[] = {
{"agentGotCapabilities", "()Z", (void*) Java_nsk_jvmti_AttachOnDemand_attach002_attach002Target_agentGotCapabilities}};
jint nativeMethodsNumber = 1;
if (!NSK_JNI_VERIFY(jni, (appClass =
NSK_CPP_STUB2(FindClass, jni, ATTACH002_TARGET_APP_CLASS_NAME)) != NULL)) {
return NSK_FALSE;
}
if (!NSK_JNI_VERIFY(jni,
(NSK_CPP_STUB4(RegisterNatives, jni, appClass, nativeMethods, nativeMethodsNumber) == 0))) {
return NSK_FALSE;
}
return NSK_TRUE;
}
void JNICALL classLoadHandler(
jvmtiEnv *jvmti,
JNIEnv* jni,
jthread thread,
jclass klass) {
char className[MAX_STRING_LENGTH];
if (!nsk_jvmti_aod_getClassName(jvmti, klass, className)) {
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
return;
}
NSK_DISPLAY2("%s: ClassLoad event was received for class '%s'\n", agentName, className);
if (!strcmp(className, REDEFINED_CLASS_NAME)) {
classLoadReceived = 1;
NSK_DISPLAY1("%s: redefining class\n", agentName);
if (!NSK_VERIFY(nsk_jvmti_aod_redefineClass(options, jvmti, klass, REDEFINED_CLASS_FILE_NAME))) {
NSK_COMPLAIN1("%s: failed to redefine class\n", agentName);
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
}
}
}
void JNICALL classPrepareHandler(
jvmtiEnv *jvmti,
JNIEnv* jni,
jthread thread,
jclass klass) {
char className[MAX_STRING_LENGTH];
if (!nsk_jvmti_aod_getClassName(jvmti, klass, className)) {
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
return;
}
NSK_DISPLAY2("%s: ClassPrepare event received for class '%s'\n", agentName, REDEFINED_CLASS_NAME);
if (!strcmp(className, REDEFINED_CLASS_NAME)) {
int success = 1;
if (!classLoadReceived) {
success = 0;
NSK_COMPLAIN2("%s: expected ClassLoad event wasn't received for class '%s'\n", agentName, REDEFINED_CLASS_NAME);
}
/*
* ClassFileLoadHook event should be received twice - when class is loaded and when class is redefined
*/
if (classFileLoadHookReceived != 2) {
success = 0;
NSK_COMPLAIN2("%s: expected ClassFileLoadHook event wasn't received for class '%s'\n", agentName, REDEFINED_CLASS_NAME);
}
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, success, jvmti, jni);
}
}
void JNICALL classFileLoadHoockHandler(
jvmtiEnv * jvmti,
JNIEnv * jni,
jclass class_beeing_redefined,
jobject loader,
const char * name,
jobject protection_domain,
jint class_data_len,
const unsigned char * class_data,
jint * new_class_data_len,
unsigned char** new_class_data) {
if (name != NULL) {
NSK_DISPLAY2("%s: ClassFileLoadHook event received for class '%s'\n", agentName, name);
if (!strcmp(name, REDEFINED_CLASS_NAME_INTERNAL)) {
classFileLoadHookReceived++;
}
} else {
NSK_DISPLAY1("%s: ClassFileLoadHook event received for class with NULL name\n", agentName);
}
}
#ifdef STATIC_BUILD
JNIEXPORT jint JNI_OnLoad_attach002Agent00(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
JNIEXPORT jint JNICALL
#ifdef STATIC_BUILD
Agent_OnAttach_attach002Agent00(JavaVM *vm, char *optionsString, void *reserved)
#else
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
#endif
{
jvmtiEventCallbacks eventCallbacks;
jvmtiCapabilities caps;
jvmtiEnv* jvmti = NULL;
JNIEnv* jni = NULL;
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
return JNI_ERR;
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
return NSK_FALSE;
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
return JNI_ERR;
if (!NSK_VERIFY(registerNativeMethods(jni))) {
return JNI_ERR;
}
memset(&caps, 0, sizeof(caps));
caps.can_generate_all_class_hook_events = 1;
caps.can_redefine_classes = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)) ) {
/*
* If VM is run with -Xshare:on agent can't get required capabilities (see 6718407)
*/
NSK_DISPLAY1("%s: warning: agent failed to get required capabilities, agent finishing\n", agentName);
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
return JNI_ERR;
nsk_aod_agentFinished(jni, agentName, 1);
} else {
agentGotCapabilities = JNI_TRUE;
memset(&eventCallbacks,0, sizeof(eventCallbacks));
eventCallbacks.ClassLoad = classLoadHandler;
eventCallbacks.ClassPrepare = classPrepareHandler;
eventCallbacks.ClassFileLoadHook = classFileLoadHoockHandler;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &eventCallbacks, sizeof(eventCallbacks))) ) {
return JNI_ERR;
}
if (!(nsk_jvmti_aod_enableEvents(jvmti, testEvents, testEventsNumber))) {
return JNI_ERR;
}
NSK_DISPLAY1("%s: initialization was done\n", agentName);
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
return JNI_ERR;
}
return JNI_OK;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,58 @@
/*
* Copyright (c) 2007, 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.jvmti.AttachOnDemand.attach002;
import nsk.share.aod.TargetApplicationWaitingAgents;
public class attach002Target extends TargetApplicationWaitingAgents {
private native boolean agentGotCapabilities();
protected void targetApplicationActions() {
/*
* If VM is run with -Xshare:on agent can't get required capabilities (see 6718407)
*/
if (!agentGotCapabilities()) {
log.display("WARNING: agent failed to get required capabilities, can't execute test checks");
} else {
final int expectedSize = 10;
/*
* ClassToRedefine should be redefined by test agent during ClassToRedefine loading,
* after redefinition method ClassToRedefine.getSize() should return value 10
*/
ClassToRedefine redefinedClassInstance = new ClassToRedefine();
int size = redefinedClassInstance.getSize();
log.display("ClassToRedefine.getSize(): " + size);
if (size != expectedSize) {
setStatusFailed("ClassToRedefine.getSize() returned unexpected value (expected is " + expectedSize + ")" +
", (probably class wasn't redefined");
}
}
}
public static void main(String[] args) {
new attach002Target().runTargetApplication(args);
}
}

@ -0,0 +1,34 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "aod.c"
#include "jvmti_aod.c"
#include "attach002Agent00.c"

@ -0,0 +1,36 @@
/*
* Copyright (c) 2008, 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.jvmti.AttachOnDemand.attach002;
import java.util.Vector;
public class ClassToRedefine {
public int getSize() {
int size = 10;
Vector<String> vector = new Vector<String>();
for (int i = 0; i < size; i++) {
vector.add("String-" + i);
}
return vector.size();
}
}

@ -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/jvmti/AttachOnDemand/attach002a.
* VM Testbase keywords: [quick, jpda, jvmti, noras, redefine, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load jvmti agent to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework. In the terms of this framework
* java application running in the VM where agent is loaded to is called 'target application'.
* This is regression test for "5002268: Allow class sharing use with RedefineClasses".
* Test tries to redefine class java.lang.InterruptedException (class from the system jar which
* is included in the shared archive).
* (5002268 was fixed in JDK6 b86, with earlier builds this test fails because of JVMTI function
* RedefineClasses fails with error JVMTI_ERROR_UNMODIFIABLE_CLASS).
* Test scenario:
* - during initialization agent tries to get capabilities 'can_generate_vm_object_alloc_events'
* and 'can_redefine_classes' and enables VMObjectAlloc events
* - target application creates instance of InterruptedException using InterruptedException.class.newInstance,
* after this agent should receive VMObjectAlloc event
* - agent receives VMObjectAlloc event, redefines InterruptedException class and finishes work
* - target application creates one more instance of Interrupted exception and checks that redefinition
* really had effect
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
*
* @comment compile newclassXX to bin/newclassXX
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/javac
* --patch-module java.base=newclass00/java.base
* -d bin/newclass00
* newclass00/java.base/java/lang/InterruptedException.java
*
* @build nsk.jvmti.AttachOnDemand.attach002a.attach002aTarget
* @run main/othervm/native PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* -target nsk.jvmti.AttachOnDemand.attach002a.attach002aTarget
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
* -na attach002aAgent00=-pathToNewByteCode=./bin/newclass00
*/

@ -0,0 +1,135 @@
/*
* Copyright (c) 2007, 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#include <jvmti.h>
#include <aod.h>
#include <jvmti_aod.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Expected agent work scenario:
* - during initialization agent enables events VMObjectAlloc
* - agent receives VMObjectAlloc event for instance of InterruptedException,
* redefines class InterruptedException and finishes work
*/
#define REDEFINED_CLASS_NAME "Ljava/lang/InterruptedException;"
#define REDEFINED_CLASS_FILE_NAME "java/lang/InterruptedException"
static Options* options = NULL;
static const char* agentName;
static jvmtiEvent testEvents[] = {JVMTI_EVENT_VM_OBJECT_ALLOC};
static const int testEventsNumber = 1;
void JNICALL vmObjectAllocHandler(jvmtiEnv * jvmti,
JNIEnv * jni,
jthread thread,
jobject object,
jclass object_class,
jlong size) {
char className[MAX_STRING_LENGTH];
if (!nsk_jvmti_aod_getClassName(jvmti, object_class, className)) {
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
return;
}
NSK_DISPLAY2("%s: ObjectAlloc event received (object class: %s)\n", agentName, className);
if (!strcmp(className, REDEFINED_CLASS_NAME)) {
int success = 1;
if (!NSK_VERIFY(nsk_jvmti_aod_redefineClass(options, jvmti, object_class, REDEFINED_CLASS_FILE_NAME))) {
NSK_COMPLAIN1("%s: failed to redefine class\n", agentName);
success = 0;
}
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, success, jvmti, jni);
}
}
#ifdef STATIC_BUILD
JNIEXPORT jint JNI_OnLoad_attach002aAgent00(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
JNIEXPORT jint JNICALL
#ifdef STATIC_BUILD
Agent_OnAttach_attach002aAgent00(JavaVM *vm, char *optionsString, void *reserved)
#else
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
#endif
{
jvmtiEventCallbacks eventCallbacks;
jvmtiCapabilities caps;
jvmtiEnv* jvmti = NULL;
JNIEnv* jni = NULL;
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
return JNI_ERR;
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
return NSK_FALSE;
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
return JNI_ERR;
memset(&caps, 0, sizeof(caps));
caps.can_redefine_classes = 1;
caps.can_generate_vm_object_alloc_events = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)) ) {
return JNI_ERR;
}
memset(&eventCallbacks,0, sizeof(eventCallbacks));
eventCallbacks.VMObjectAlloc = vmObjectAllocHandler;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &eventCallbacks, sizeof(eventCallbacks))) ) {
return JNI_ERR;
}
if (!(nsk_jvmti_aod_enableEvents(jvmti, testEvents, testEventsNumber))) {
return JNI_ERR;
}
NSK_DISPLAY1("%s: initialization was done\n", agentName);
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
return JNI_ERR;
return JNI_OK;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,53 @@
/*
* Copyright (c) 2007, 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.jvmti.AttachOnDemand.attach002a;
import nsk.share.aod.TargetApplicationWaitingAgents;
public class attach002aTarget extends TargetApplicationWaitingAgents {
protected void targetApplicationActions() throws Throwable {
/*
* Provoke VMObjectAlloc event, InterruptedException class is redefined
* in the handler for this event
*/
InterruptedException e = InterruptedException.class.newInstance();
// here redefined class version should be used
e = new InterruptedException("Test InterruptedException");
String message = e.getMessage();
log.display("InterruptedException.getMessage(): '" + message + "'");
final String expectedMessage = "attach002a: redefined version";
if (!message.equals(expectedMessage)) {
setStatusFailed("InterruptedException.getMessage() returns unexpected value " +
"(expected is '" + expectedMessage + "')" +
", probably class wasn't redefined");
}
}
public static void main(String[] args) {
new attach002aTarget().runTargetApplication(args);
}
}

@ -0,0 +1,34 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "aod.c"
#include "jvmti_aod.c"
#include "attach002aAgent00.c"

@ -0,0 +1,37 @@
/*
* Copyright (c) 2007, 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 java.lang;
public class InterruptedException extends Exception {
// real value does not matter JVM TI require same field
private static final long serialVersionUID = 6700697376100628473L;
public InterruptedException() {
super("attach002a: redefined version");
}
public InterruptedException(String s) {
super("attach002a: redefined version");
}
}

@ -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/jvmti/AttachOnDemand/attach003.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load 2 java agents to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework. In this framework each java
* agent starts new thread from the 'agentmain' method, and all test checks are executed
* in this thread. Also in the terms of this framework java application running in the
* VM where agent is loaded to is called 'target application'.
* This test just checks that java agents can be loaded and run. Test attaches 2 java agents
* displaying all classes loaded in the target application using method Instrumentation.getAllLoadedClasses
* (the same agent is attached twice).
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
* nsk.share.aod.TargetApplicationWaitingAgents
*
* @comment create SimpleAgent00.jar in current directory
* @build nsk.jvmti.AttachOnDemand.sharedAgents.SimpleAgent00
* @run driver ClassFileInstaller nsk.jvmti.AttachOnDemand.sharedAgents.SimpleAgent00
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cfm SimpleAgent00.jar ${test.src}/../sharedAgents/SimpleAgent00.mf
* nsk/jvmti/AttachOnDemand/sharedAgents/SimpleAgent00.class
*
* @run main/othervm PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
* -target nsk.share.aod.TargetApplicationWaitingAgents
* -ja SimpleAgent00.jar,SimpleAgent00.jar
*/

@ -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/jvmti/AttachOnDemand/attach004.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load java agent to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework. In this framework each java
* agent starts new thread from the 'agentmain' method, and all test checks are executed
* in this thread. Also in the terms of this framework java application running in the
* VM where agent is loaded to is called 'target application'.
* In this test target application is running with enabled security manager and with restricted
* permissions. Test checks that loaded agent is also run with restricted permissions (attempt
* to create ClassLoader should fail with SecurityException).
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
* nsk.share.aod.TargetApplicationWaitingAgents
*
* @comment create attach004Agent00.jar in current directory
* @build nsk.jvmti.AttachOnDemand.attach004.attach004Agent00
* @run driver ClassFileInstaller nsk.jvmti.AttachOnDemand.attach004.attach004Agent00
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cfm attach004Agent00.jar ${test.src}/attach004Agent00.mf
* nsk/jvmti/AttachOnDemand/attach004/attach004Agent00.class
*
* @run main/othervm PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts} -Djava.security.manager -Djava.security.policy==${test.src}/attach004.policy"
* -target nsk.share.aod.TargetApplicationWaitingAgents
* -ja attach004Agent00.jar
*/

@ -0,0 +1,9 @@
grant {
permission java.net.SocketPermission "*:0-", "listen,connect,resolve";
permission java.lang.RuntimePermission "modifyThreadGroup";
permission java.lang.RuntimePermission "modifyThread";
permission java.lang.RuntimePermission "shutdownHooks";
permission java.util.PropertyPermission "vmsqe.aod.AppId", "read";
permission java.io.FilePermission "${vmsqe.aod.AppId}", "read";
permission java.io.FilePermission "${vmsqe.aod.AppId}", "delete";
};

@ -0,0 +1,58 @@
/*
* Copyright (c) 2007, 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.jvmti.AttachOnDemand.attach004;
import nsk.share.aod.AbstractJarAgent;
import java.lang.instrument.Instrumentation;
public class attach004Agent00 extends AbstractJarAgent {
static class TestClassLoader extends ClassLoader {
}
protected void agentActions() throws Throwable {
if (System.getSecurityManager() == null) {
setStatusFailed("System.getSecurityManager() returns null");
return;
}
try {
/*
* Target application should be run with restricted permissions
* and attempt to create ClassLoader from the agent should fail
* with SecurityException
*/
TestClassLoader classLoader = new TestClassLoader();
display("ClassLoader created: " + classLoader);
setStatusFailed("Expected SecurityException wasn't thrown");
} catch (SecurityException e) {
display("Expected SecurityException: " + e);
logThrowable(e);
}
}
public static void agentmain(String options, Instrumentation inst) {
new attach004Agent00().runJarAgent(options, inst);
}
}

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Agent-Class: nsk.jvmti.AttachOnDemand.attach004.attach004Agent00

@ -0,0 +1,53 @@
/*
* 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/jvmti/AttachOnDemand/attach008.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load jvmti agent to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework. In the terms of this framework
* java application running in the VM where agent is loaded to is called 'target application'.
* Test performs following checks:
* - loaded agent can get capability 'can_generate_monitor_events'
* - agent receives events MonitorContentedEnter, MonitorContentedEntered
* (these events are provoked by target application)
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
* nsk.jvmti.AttachOnDemand.attach008.attach008Target
* @run main/othervm/native PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* -target nsk.jvmti.AttachOnDemand.attach008.attach008Target
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
* -na attach008Agent00
*/

@ -0,0 +1,153 @@
/*
* Copyright (c) 2007, 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#include <jvmti.h>
#include <aod.h>
#include <jvmti_aod.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Expected agent work scenario:
* - receive MonitorContentedEnter event for thread ThreadGeneratingEvents
* - receive MonitorContentedEntered event for thread ThreadGeneratingEvents and finish work
*/
#define THREAD_GENERATING_EVENTS_NAME "ThreadGeneratingEvents"
static Options* options = NULL;
static const char* agentName;
static jvmtiEvent testEvents[] = {JVMTI_EVENT_MONITOR_CONTENDED_ENTER, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED};
static const int testEventsNumber = 2;
static volatile int monitorEnter = 0;
static int success = 1;
void JNICALL monitorContentedEnterHandler(jvmtiEnv * jvmti,
JNIEnv * jni,
jthread thread,
jobject object) {
char threadName[MAX_STRING_LENGTH];
if (!nsk_jvmti_aod_getThreadName(jvmti, thread, threadName)) {
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
return;
}
NSK_DISPLAY2("%s: MonitorContentedEnter event received for thread '%s'\n", agentName, threadName);
if (!strcmp(threadName, THREAD_GENERATING_EVENTS_NAME)) {
monitorEnter = 1;
}
}
void JNICALL monitorContentedEnteredHandler(
jvmtiEnv * jvmti,
JNIEnv * jni,
jthread thread,
jobject object) {
char threadName[MAX_STRING_LENGTH];
if(!nsk_jvmti_aod_getThreadName(jvmti, thread, threadName)) {
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
return;
}
NSK_DISPLAY2("%s: MonitorContentedEntered event received for thread '%s'\n", agentName, threadName);
if (!strcmp(threadName, THREAD_GENERATING_EVENTS_NAME)) {
int success = 1;
if (!monitorEnter) {
success = 0;
NSK_COMPLAIN2("%s: MonitorContentedEnter event wasn't received for thread %s\n", agentName, threadName);
}
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, success, jvmti, jni);
}
}
#ifdef STATIC_BUILD
JNIEXPORT jint JNI_OnLoad_attach008Agent00(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
JNIEXPORT jint JNICALL
#ifdef STATIC_BUILD
Agent_OnAttach_attach008Agent00(JavaVM *vm, char *optionsString, void *reserved)
#else
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
#endif
{
jvmtiEventCallbacks eventCallbacks;
jvmtiCapabilities caps;
jvmtiEnv* jvmti = NULL;
JNIEnv* jni = NULL;
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
return JNI_ERR;
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
return NSK_FALSE;
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
return JNI_ERR;
memset(&caps, 0, sizeof(caps));
caps.can_generate_monitor_events = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)) ) {
return JNI_ERR;
}
memset(&eventCallbacks,0, sizeof(eventCallbacks));
eventCallbacks.MonitorContendedEntered = monitorContentedEnteredHandler;
eventCallbacks.MonitorContendedEnter = monitorContentedEnterHandler;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &eventCallbacks, sizeof(eventCallbacks))) ) {
return JNI_ERR;
}
if (!(nsk_jvmti_aod_enableEvents(jvmti, testEvents, testEventsNumber))) {
return JNI_ERR;
}
NSK_DISPLAY1("%s: initialization was done\n", agentName);
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
return JNI_ERR;
return JNI_OK;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,76 @@
/*
* Copyright (c) 2007, 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.jvmti.AttachOnDemand.attach008;
import nsk.share.aod.TargetApplicationWaitingAgents;
import nsk.share.locks.MonitorLockingThread;
public class attach008Target extends TargetApplicationWaitingAgents {
/*
* Thread generates MonitorContentedEnter/MonitorContentedEntered events
*/
static class ThreadGeneratingEvents extends Thread {
ThreadGeneratingEvents() {
super("ThreadGeneratingEvents");
}
public void run() {
try {
Object lock = new Object();
MonitorLockingThread monitorLockingThread = new MonitorLockingThread(lock);
MonitorLockingThread.LockFreeThread lockFreeThread =
new MonitorLockingThread.LockFreeThread(Thread.currentThread(), monitorLockingThread);
monitorLockingThread.acquireLock();
lockFreeThread.start();
log.display(Thread.currentThread() + ": trying to acquire lock");
// try to acquire lock which is already held by MonitorLockingThread
synchronized (lock) {
log.display(Thread.currentThread() + ": lock is acquired");
}
lockFreeThread.join();
monitorLockingThread.join();
} catch (Throwable t) {
setStatusFailed("Unexpected exception: " + t);
t.printStackTrace(log.getOutStream());
}
}
}
protected void targetApplicationActions() throws InterruptedException {
ThreadGeneratingEvents threadGeneratingEvents = new ThreadGeneratingEvents();
threadGeneratingEvents.start();
threadGeneratingEvents.join();
}
public static void main(String[] args) {
new attach008Target().runTargetApplication(args);
}
}

@ -0,0 +1,34 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "aod.c"
#include "jvmti_aod.c"
#include "attach008Agent00.c"

@ -0,0 +1,52 @@
/*
* 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/jvmti/AttachOnDemand/attach009.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load jvmti agent to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework. In the terms of this framework
* java application running in the VM where agent is loaded to is called 'target application'.
* Test performs following checks:
* - agent receives ClassLoad events (these events are provoked by target application)
* - agent can disable ClassLoad events for all threads except one
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
* nsk.jvmti.AttachOnDemand.attach009.attach009Target
* @run main/othervm/native PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* -target nsk.jvmti.AttachOnDemand.attach009.attach009Target
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
* -na attach009Agent00
*/

@ -0,0 +1,165 @@
/*
* Copyright (c) 2007, 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#include <jvmti.h>
#include <aod.h>
#include <jvmti_aod.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Expected agent work scenario:
* - receive ClassLoad event for class FirstLoadedClass, from handler for this event
* disable ClassLoad events for all threads except thread loading FirstLoadedClass
* (after these ClassLoad events should come only from this thread)
* - receive ClassLoad event for class LastLoadedClass and finish work
*/
static Options* options = NULL;
static const char* agentName;
#define FIRST_LOADED_CLASS "Lnsk/jvmti/AttachOnDemand/attach009/FirstLoadedClass;"
#define LAST_LOADED_CLASS "Lnsk/jvmti/AttachOnDemand/attach009/LastLoadedClass;"
static int disabledForOthers = 0;
static volatile int success = 1;
void JNICALL
classLoadHandler(jvmtiEnv *jvmti,
JNIEnv* jni,
jthread thread,
jclass klass) {
static char mainThreadName[MAX_STRING_LENGTH];
char loadedClassName[MAX_STRING_LENGTH];
char threadName[MAX_STRING_LENGTH];
if (!nsk_jvmti_aod_getThreadName(jvmti, thread, threadName)) {
nsk_jvmti_aod_disableEventAndFinish(agentName, JVMTI_EVENT_CLASS_LOAD, 0, jvmti, jni);
return;
}
if (!nsk_jvmti_aod_getClassName(jvmti, klass, loadedClassName)) {
nsk_jvmti_aod_disableEventAndFinish(agentName, JVMTI_EVENT_CLASS_LOAD, 0, jvmti, jni);
return;
}
NSK_DISPLAY2("Class '%s' was loaded by thread '%s'\n", loadedClassName, threadName);
/*
* When class FIRST_LOADED_CLASS was loaded try to disable events for all threads
* except main target application thread
*/
if (strcmp(loadedClassName, FIRST_LOADED_CLASS) == 0) {
strcpy(mainThreadName, threadName);
if (!nsk_jvmti_aod_disableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD)) {
NSK_COMPLAIN0("Failed to disable events\n");
nsk_aod_agentFinished(jni, agentName, 0);
return;
}
if (!NSK_JVMTI_VERIFY( NSK_CPP_STUB4(
SetEventNotificationMode, jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, thread) ) ) {
NSK_COMPLAIN1("Failed to enable events for thread '%s'\n", mainThreadName);
nsk_aod_agentFinished(jni, agentName, 0);
return;
}
NSK_DISPLAY1("ClassLoad events are enabled only for thread '%s'", mainThreadName);
disabledForOthers = 1;
return;
}
if (disabledForOthers) {
if (strcmp(threadName, mainThreadName) != 0) {
success = 0;
NSK_COMPLAIN1("ClassLoad event was erroneously generated for thread '%s'\n", threadName);
}
}
/*
* Stop agent when LAST_LOADED_CLASS was loaded
*/
if (strcmp(loadedClassName, LAST_LOADED_CLASS) == 0) {
nsk_jvmti_aod_disableEventAndFinish(agentName, JVMTI_EVENT_CLASS_LOAD, success, jvmti, jni);
}
}
#ifdef STATIC_BUILD
JNIEXPORT jint JNI_OnLoad_attach009Agent00(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
JNIEXPORT jint JNICALL
#ifdef STATIC_BUILD
Agent_OnAttach_attach009Agent00(JavaVM *vm, char *optionsString, void *reserved)
#else
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
#endif
{
jvmtiEnv* jvmti;
jvmtiEventCallbacks eventCallbacks;
JNIEnv* jni;
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
return JNI_ERR;
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
return NSK_FALSE;
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
return JNI_ERR;
memset(&eventCallbacks,0, sizeof(eventCallbacks));
eventCallbacks.ClassLoad = classLoadHandler;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &eventCallbacks, sizeof(eventCallbacks))) ) {
return JNI_ERR;
}
if (!(nsk_jvmti_aod_enableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD))) {
return JNI_ERR;
}
NSK_DISPLAY1("%s: initialization was done\n", agentName);
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
return JNI_ERR;
return JNI_OK;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,103 @@
/*
* Copyright (c) 2007, 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.jvmti.AttachOnDemand.attach009;
import nsk.share.aod.TargetApplicationWaitingAgents;
class FirstLoadedClass {
}
class ClassToLoad0 {
}
class ClassToLoad1 {
}
class ClassToLoad2 {
}
class LastLoadedClass {
}
public class attach009Target extends TargetApplicationWaitingAgents {
private void loadClass(String className) {
try {
Class.forName(className, true, this.getClass().getClassLoader());
} catch (Throwable t ){
setStatusFailed("Unexpected exception during class loading: " + t);
t.printStackTrace(log.getOutStream());
}
}
class ClassLoadingThread extends Thread {
String className;
ClassLoadingThread(String className) {
this.className = className;
}
public void run() {
log.display(Thread.currentThread() + " is loading class '" + className + "'");
loadClass(className);
}
}
protected void targetApplicationActions() throws Throwable {
/*
* Test checks that ClassLoad event can be enabled only for one thread
* (for target application thread executing method targetApplicationActions()).
*
* Method targetApplicationActions() does following:
* - loads class 'FirstLoadedClass', after this ClassLoad evens enabled only for the current thread
* - starts several threads loading classes (for these threads ClassLoad events shoudn't be generated)
* - loads class 'LastLoadedClass', after this test agent should finish work
*/
ClassLoadingThread classLoadingThreads[] = new ClassLoadingThread[3];
for (int i = 0; i < classLoadingThreads.length; i++) {
classLoadingThreads[i] = new ClassLoadingThread("nsk.jvmti.AttachOnDemand.attach009.ClassToLoad" + i);
classLoadingThreads[i].setName("ClassLoadingThread-" + i);
}
loadClass("nsk.jvmti.AttachOnDemand.attach009.FirstLoadedClass");
for (ClassLoadingThread classLoadingThread : classLoadingThreads)
classLoadingThread.start();
for (ClassLoadingThread classLoadingThread : classLoadingThreads)
classLoadingThread.join();
loadClass("nsk.jvmti.AttachOnDemand.attach009.LastLoadedClass");
}
public static void main(String[] args) {
new attach009Target().runTargetApplication(args);
}
}

@ -0,0 +1,34 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "aod.c"
#include "jvmti_aod.c"
#include "attach009Agent00.c"

@ -0,0 +1,61 @@
/*
* 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/jvmti/AttachOnDemand/attach010.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load java agent to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework. In this framework each java
* agent starts new thread from the 'agentmain' method, and all test checks are executed
* in this thread.
* This test checks that loaded agent can use and change streams System.in, System.out and System.err.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
* nsk.share.aod.TargetApplicationWaitingAgents
*
* @comment create attach010Agent00.jar in current directory
* @build nsk.jvmti.AttachOnDemand.attach010.attach010Agent00
* @run driver ClassFileInstaller nsk.jvmti.AttachOnDemand.attach010.attach010Agent00
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cfm attach010Agent00.jar ${test.src}/attach010Agent00.mf
* nsk/jvmti/AttachOnDemand/attach010/attach010Agent00.class
*
* @run main/othervm PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
* -target nsk.share.aod.TargetApplicationWaitingAgents
* -ja attach010Agent00.jar
*/

@ -0,0 +1,74 @@
/*
* Copyright (c) 2007, 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.jvmti.AttachOnDemand.attach010;
import nsk.share.aod.AbstractJarAgent;
import java.io.*;
import java.lang.instrument.Instrumentation;
public class attach010Agent00 extends AbstractJarAgent {
private static final String outStreamFileName = "AttachOnDemand.attach010.out";
private static final String errStreamFileName = "AttachOnDemand.attach010.err";
private static final String inStreamFileName = "AttachOnDemand.attach010.in";
protected void agentActions() throws Throwable {
PrintStream newOutStream = new PrintStream(outStreamFileName);
PrintStream newErrStream = new PrintStream(errStreamFileName);
System.setOut(newOutStream);
System.out.println("Print to the new System.out");
System.setErr(newErrStream);
System.err.println("Print to the new System.err");
/*
* Check input stream
*/
final int valueToWrite = 100;
PrintStream inputFileStream = new PrintStream(inStreamFileName);
try {
inputFileStream.println(valueToWrite);
} finally {
inputFileStream.close();
}
FileInputStream newInputStream = new FileInputStream(inStreamFileName);
System.setIn(newInputStream);
BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(System.in));
int readValue = Integer.parseInt(inputStreamReader.readLine());
if (readValue != valueToWrite) {
setStatusFailed("Unexpected value was read from input stream: " + readValue + ", expected value is " + valueToWrite);
}
}
public static void agentmain(String options, Instrumentation inst) {
new attach010Agent00().runJarAgent(options, inst);
}
}

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Agent-Class: nsk.jvmti.AttachOnDemand.attach010.attach010Agent00

@ -0,0 +1,62 @@
/*
* 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/jvmti/AttachOnDemand/attach011.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load java and jvmti agents to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework. In this framework each java
* agent starts new thread from the 'agentmain' method, and all test checks are executed
* in this thread.
* This test just checks that java and jvmti agents can be loaded in the same VM.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
* nsk.share.aod.TargetApplicationWaitingAgents
*
* @comment create SimpleAgent00.jar in current directory
* @build nsk.jvmti.AttachOnDemand.sharedAgents.SimpleAgent00
* @run driver ClassFileInstaller nsk.jvmti.AttachOnDemand.sharedAgents.SimpleAgent00
* @build ExecDriver
* @run driver PropertyResolvingWrapper ExecDriver --cmd
* ${compile.jdk}/bin/jar
* -cfm SimpleAgent00.jar ${test.src}/../sharedAgents/SimpleAgent00.mf
* nsk/jvmti/AttachOnDemand/sharedAgents/SimpleAgent00.class
*
* @run main/othervm/native PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
* -target nsk.share.aod.TargetApplicationWaitingAgents
* -na simpleAgent00
* -ja SimpleAgent00.jar
*/

@ -0,0 +1,52 @@
/*
* 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/jvmti/AttachOnDemand/attach012.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load jvmti agent to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework.
* This test checks that jvmti agents can get all potential capabilities
* (capabilities returned by the JVMTI function GetPotentialCapabilities).
* Agent just checks that function AddCapabilities doesn't fail, and doesn't
* check that all requested capabilities were really added.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
* nsk.share.aod.TargetApplicationWaitingAgents
* @run main/othervm/native PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
* -target nsk.share.aod.TargetApplicationWaitingAgents
* -na attach012Agent00
*/

@ -0,0 +1,96 @@
/*
* Copyright (c) 2008, 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#include <jvmti.h>
#include <aod.h>
#include <jvmti_aod.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Agent tries to get all potential capabilities
* (capabilities returned by the JVMTI function GetPotentialCapabilities)
*/
#ifdef STATIC_BUILD
JNIEXPORT jint JNI_OnLoad_attach012Agent00(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
JNIEXPORT jint JNICALL
#ifdef STATIC_BUILD
Agent_OnAttach_attach012Agent00(JavaVM *vm, char *optionsString, void *reserved)
#else
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
#endif
{
jvmtiEnv* jvmti;
JNIEnv* jni = NULL;
Options* options = NULL;
const char* agentName;
jvmtiCapabilities caps;
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
return JNI_ERR;
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
return NSK_FALSE;
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPotentialCapabilities, jvmti, &caps)) ) {
return JNI_ERR;
}
NSK_DISPLAY1("%s: potential capabilities:\n", agentName);
printCapabilities(caps);
NSK_DISPLAY1("%s: trying to get all potential capabilities:\n", agentName);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)) ) {
return JNI_ERR;
}
NSK_DISPLAY1("%s: initialization was done\n", agentName);
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
return JNI_ERR;
nsk_aod_agentFinished(jni, agentName, 1);
return JNI_OK;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,34 @@
/*
* 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.
*/
#include "native_thread.c"
#include "nsk_tools.c"
#include "jni_tools.c"
#include "jvmti_tools.c"
#include "agent_tools.c"
#include "jvmti_FollowRefObjects.c"
#include "Injector.c"
#include "JVMTITools.c"
#include "aod.c"
#include "jvmti_aod.c"
#include "attach012Agent00.c"

@ -0,0 +1,50 @@
/*
* 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/jvmti/AttachOnDemand/attach013.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load 3 jvmti agents to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework.
* This test just checks that 3 jvmti agents can be loaded in the same VM
* (the same agent library is attached 3 times).
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
* nsk.share.aod.TargetApplicationWaitingAgents
* @run main/othervm/native PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
* -target nsk.share.aod.TargetApplicationWaitingAgents
* -na simpleAgent00,simpleAgent00,simpleAgent00
*/

@ -0,0 +1,49 @@
/*
* 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/jvmti/AttachOnDemand/attach014.
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
* VM Testbase readme:
* Description :
* Test tries to load jvmti agent to the VM after the VM has started using
* Attach API (com.sun.tools.attach).
* Test is based on the nsk.share.aod framework.
* Test checks that attached native agent can call JVMTI function DisposeEnvironment.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.share.aod.AODTestRunner
* nsk.jvmti.AttachOnDemand.attach014.attach014Target
* @run main/othervm/native PropertyResolvingWrapper
* nsk.share.aod.AODTestRunner
* -jdk ${test.jdk}
* -target nsk.jvmti.AttachOnDemand.attach014.attach014Target
* "-javaOpts=-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
* -na attach014Agent00
*/

Some files were not shown because too many files have changed in this diff Show More