RFR: 8267796: vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/TestDescription.java fails with NoClassDefFoundError
Alex Menkov
amenkov at openjdk.java.net
Thu Feb 24 13:28:33 UTC 2022
On Thu, 24 Feb 2022 12:44:18 GMT, Alex Menkov <amenkov at openjdk.org> wrote:
> The fix adds workaround in hs201t001a class like we have in hs201t001 test to avoid class loading while the test do single stepping/pop frame.
> Also fixed a number of issues in the test.
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/TestDescription.java line 74:
> 72: *
> 73: * @run main/othervm/native
> 74: * -agentlib:hs201t002=pathToNewByteCode=./bin,-waittime=5,-verbose
Adds verbose output for the test and agent
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp line 48:
> 46:
> 47: static jint testStep;
> 48: static int redefineNumber;
not used
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp line 127:
> 125: nsk_jvmti_setFailStatus();
> 126: }
> 127: if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate(newClassBytes))) {
proper resource deallocation
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp line 334:
> 332: jclass klass;
> 333:
> 334: NSK_DISPLAY2("\n\n>>>> Exception %s in thread - %s\n",
getClassName() and getThreadName() used the same global buffer to return results. So thread name overrides class name and in log we see:
>>>> Exception hs201t002Thread in thread - hs201t002Thread
instead of
>>>> Exception Lnsk/jvmti/scenarios/hotswap/HS201/hs201t002a; in thread - hs201t002Thread
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp line 382:
> 380: /* ============================================================================= */
> 381:
> 382: int readNewBytecode(jvmtiEnv* jvmti, jint &newClassSize, unsigned char* &newClassBytes) {
The function returns loaded data instead of using global variable for correct resource management
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp line 429:
> 427: /* ============================================================================= */
> 428:
> 429: const char* getThreadName(jvmtiEnv* jvmti_env, JNIEnv* jni_env, jthread thread) {
The function now returns JVMTI allocated buffer instead of global buffer
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp line 468:
> 466: /* ============================================================================= */
> 467:
> 468: const char* getClassName(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jobject object) {
The function now returns JVMTI allocated buffer instead of global buffer
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp line 668:
> 666: NSK_DISPLAY0("Enable events\n");
> 667:
> 668: enableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD, testedThread);
This code executed on agent initialization, the test has no chance to set testThread.
Moved to hs201t002.setThread()
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/newclass/hs201t002a.java line 29:
> 27:
> 28: public hs201t002a () {
> 29: System.out.println("Current step: " + hs201t002.currentStep); // Avoid calling classloader to find hs201t002 in doInit()
This is the fix for the failure, the rest are test improvements
-------------
PR: https://git.openjdk.java.net/jdk/pull/7607
More information about the serviceability-dev
mailing list