From 26211cd505d6f5b2059f3f63aa1ad4e1dcc54302 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Thu, 16 May 2024 02:03:18 +0000 Subject: [PATCH 1/5] 8299023: TestPLABResize.java and TestPLABPromotion.java are failing intermittently Backport-of: f50df105912858198809b50432ef5a4ab184528d --- test/hotspot/jtreg/gc/g1/plab/TestPLABPromotion.java | 4 ++-- test/hotspot/jtreg/gc/g1/plab/TestPLABResize.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/gc/g1/plab/TestPLABPromotion.java b/test/hotspot/jtreg/gc/g1/plab/TestPLABPromotion.java index d94bdd3a2a9..836c48624a0 100644 --- a/test/hotspot/jtreg/gc/g1/plab/TestPLABPromotion.java +++ b/test/hotspot/jtreg/gc/g1/plab/TestPLABPromotion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 @@ -26,7 +26,7 @@ * @bug 8141278 8141141 * @summary Test PLAB promotion * @requires vm.gc.G1 - * @requires !vm.flightRecorder + * @requires vm.flagless * @library /test/lib / * @modules java.base/jdk.internal.misc * @modules java.management diff --git a/test/hotspot/jtreg/gc/g1/plab/TestPLABResize.java b/test/hotspot/jtreg/gc/g1/plab/TestPLABResize.java index f812fbd98c0..ae5b618c289 100644 --- a/test/hotspot/jtreg/gc/g1/plab/TestPLABResize.java +++ b/test/hotspot/jtreg/gc/g1/plab/TestPLABResize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 @@ -26,7 +26,7 @@ * @bug 8141278 8141141 * @summary Test for PLAB resizing * @requires vm.gc.G1 - * @requires !vm.flightRecorder + * @requires vm.flagless * @library /test/lib / * @modules java.base/jdk.internal.misc * @modules java.management From 83b05c4d57efa63018bdf1fdedf2dc5352613593 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Thu, 16 May 2024 07:31:50 +0000 Subject: [PATCH 2/5] 8318322: Update IANA Language Subtag Registry to Version 2023-10-16 Backport-of: 3460807ba6d8419b679c857ccfdc68c4a06a3ac9 --- .../data/lsrdata/language-subtag-registry.txt | 52 ++++++++++++++++++- .../Locale/LanguageSubtagRegistryTest.java | 4 +- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/make/data/lsrdata/language-subtag-registry.txt b/make/data/lsrdata/language-subtag-registry.txt index 85e0822ed13..c6937ee80f1 100644 --- a/make/data/lsrdata/language-subtag-registry.txt +++ b/make/data/lsrdata/language-subtag-registry.txt @@ -1,4 +1,4 @@ -File-Date: 2023-08-02 +File-Date: 2023-10-16 %% Type: language Subtag: aa @@ -44880,6 +44880,11 @@ Description: Cherokee Added: 2005-10-16 %% Type: script +Subtag: Chis +Description: Chisoi +Added: 2023-10-16 +%% +Type: script Subtag: Chrs Description: Chorasmian Added: 2019-09-11 @@ -44975,6 +44980,11 @@ Description: Ge'ez Added: 2005-10-16 %% Type: script +Subtag: Gara +Description: Garay +Added: 2023-10-16 +%% +Type: script Subtag: Geok Description: Khutsuri (Asomtavruli and Nuskhuri) Added: 2005-10-16 @@ -45020,6 +45030,11 @@ Description: Gujarati Added: 2005-10-16 %% Type: script +Subtag: Gukh +Description: Gurung Khema +Added: 2023-10-16 +%% +Type: script Subtag: Guru Description: Gurmukhi Added: 2005-10-16 @@ -45190,6 +45205,11 @@ Description: Kpelle Added: 2010-04-10 %% Type: script +Subtag: Krai +Description: Kirat Rai +Added: 2023-10-16 +%% +Type: script Subtag: Kthi Description: Kaithi Added: 2007-12-05 @@ -45437,6 +45457,11 @@ Description: Santali Added: 2006-07-21 %% Type: script +Subtag: Onao +Description: Ol Onal +Added: 2023-10-16 +%% +Type: script Subtag: Orkh Description: Old Turkic Description: Orkhon Runic @@ -45616,6 +45641,11 @@ Description: Siddhamātṛkā Added: 2013-12-02 %% Type: script +Subtag: Sidt +Description: Sidetic +Added: 2023-10-16 +%% +Type: script Subtag: Sind Description: Khudawadi Description: Sindhi @@ -45719,6 +45749,11 @@ Description: Tai Viet Added: 2007-12-05 %% Type: script +Subtag: Tayo +Description: Tai Yo +Added: 2023-10-16 +%% +Type: script Subtag: Telu Description: Telugu Added: 2005-10-16 @@ -45767,11 +45802,26 @@ Description: Tangsa Added: 2021-03-05 %% Type: script +Subtag: Todr +Description: Todhri +Added: 2023-10-16 +%% +Type: script +Subtag: Tols +Description: Tolong Siki +Added: 2023-10-16 +%% +Type: script Subtag: Toto Description: Toto Added: 2020-05-12 %% Type: script +Subtag: Tutg +Description: Tulu-Tigalari +Added: 2023-10-16 +%% +Type: script Subtag: Ugar Description: Ugaritic Added: 2005-10-16 diff --git a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java index aa8e8c2c6f5..d0141b304a8 100644 --- a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java +++ b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java @@ -24,9 +24,9 @@ /* * @test * @bug 8025703 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432 - * 8258795 8267038 8287180 8302512 8304761 8306031 8308021 8313702 + * 8258795 8267038 8287180 8302512 8304761 8306031 8308021 8313702 8318322 * @summary Checks the IANA language subtag registry data update - * (LSR Revision: 2023-08-02) with Locale and Locale.LanguageRange + * (LSR Revision: 2023-10-16) with Locale and Locale.LanguageRange * class methods. * @run main LanguageSubtagRegistryTest */ From 92fa3e4ba66a0c508683f029c964553892afb95f Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Thu, 16 May 2024 09:46:21 +0000 Subject: [PATCH 3/5] 8326521: JFR: CompilerPhase event test fails on windows 32 bit Backport-of: 96530bcc07514c3eda40fd6ffa74f197fe541dea --- test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java index e043736d1d7..7c1b762cf71 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java @@ -45,6 +45,7 @@ * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm -Xbootclasspath/a:. + * -XX:-NeverActAsServerClassMachine * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:CompileOnly=jdk.jfr.event.compiler.TestCompilerPhase::dummyMethod * -XX:+SegmentedCodeCache -Xbootclasspath/a:. From b6a5d0b30e8ba9cddcc46eba5b15bd6ab8b6d907 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 16 May 2024 10:19:02 +0000 Subject: [PATCH 4/5] 8297082: Remove sun/tools/jhsdb/BasicLauncherTest.java from problem list Reviewed-by: mbaesken Backport-of: e552509bcbbba5562219355841cf3dedd7daaeb8 --- test/jdk/ProblemList.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 4c23f817d23..155e1330db7 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -823,10 +823,9 @@ java/awt/event/MouseEvent/SpuriousExitEnter/SpuriousExitEnter.java 8254841 macos # svc_tools sun/tools/jstat/jstatClassloadOutput1.sh 8173942 generic-all -sun/tools/jhsdb/BasicLauncherTest.java 8193639,8211767 linux-ppc64,linux-ppc64le,solaris-all +sun/tools/jhsdb/BasicLauncherTest.java 8193639 solaris-all sun/tools/jhsdb/HeapDumpTest.java 8193639 solaris-all - ############################################################################ # jdk_other From ed7cbd8424aefceefd59bcdc5ac465a8c27e2206 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Fri, 17 May 2024 08:06:56 +0000 Subject: [PATCH 5/5] 8267796: vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/TestDescription.java fails with NoClassDefFoundError Reviewed-by: mdoerr Backport-of: f12200cd11c2b689618cde1902db941ee23fbf80 --- .../scenarios/hotswap/HS201/hs201t002.java | 28 +++- .../HS201/hs201t002/TestDescription.java | 6 +- .../hotswap/HS201/hs201t002/hs201t002.cpp | 157 ++++++++---------- .../HS201/hs201t002/newclass/hs201t002a.java | 3 +- 4 files changed, 102 insertions(+), 92 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002.java index e8a874f4c27..c76a9b005d1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2022, 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 @@ -24,6 +24,7 @@ package nsk.jvmti.scenarios.hotswap.HS201; import java.io.PrintStream; +import java.util.concurrent.CountDownLatch; import nsk.share.*; import nsk.share.jvmti.*; @@ -73,14 +74,23 @@ public int runIt(String args[], PrintStream out) { timeout = argHandler.getWaitTime() * 60 * 1000; // milliseconds log.display(">>> starting tested thread"); - Thread thread = new hs201t002Thread(); + hs201t002Thread thread = new hs201t002Thread(); // testing sync status = checkStatus(status); - setThread(thread); thread.start(); + // setThread(thread) enables JVMTI events, and that can only be done on a live thread, + // so wait until the thread has started. + try { + thread.ready.await(); + } catch (InterruptedException e) { + } + setThread(thread); + + thread.go.countDown(); + while (currentStep != 4) { try { Thread.sleep(100); @@ -114,6 +124,10 @@ public int runIt(String args[], PrintStream out) { } log.display("Thread suspended in a wrong moment. Retrying..."); + for (int i = 0; i < stackTrace.length; i++) { + log.display("\t" + i + ". " + stackTrace[i]); + } + log.display("Retrying..."); resumeThread(thread); suspendTry++; // Test thread will be suspended at the top of the loop. Let it run for a while. @@ -136,12 +150,20 @@ public int runIt(String args[], PrintStream out) { class hs201t002Thread extends Thread { + CountDownLatch ready = new CountDownLatch(1); + CountDownLatch go = new CountDownLatch(1); + hs201t002Thread() { setName("hs201t002Thread"); } public void run() { // run method + ready.countDown(); + try { + go.await(); + } catch (InterruptedException e) { + } try { throwException(); } catch (Exception e) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/TestDescription.java index cff920a9ebf..3e67a90c0c7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022, 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 @@ -73,7 +73,7 @@ * * @build ExecDriver * @run main/othervm/native PropertyResolvingWrapper ExecDriver --java - * "-agentlib:hs201t002=pathToNewByteCode=./bin -waittime=5" - * nsk.jvmti.scenarios.hotswap.HS201.hs201t002 + * -agentlib:hs201t002=pathToNewByteCode=./bin,-waittime=5,-verbose + * nsk.jvmti.scenarios.hotswap.HS201.hs201t002 -verbose */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp index a8aa4b98b0b..b5d63944b0b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2022, 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 @@ -45,16 +45,18 @@ static jlong timeout = 0; #define PATH_TO_NEW_BYTECODE "pathToNewByteCode" static jint testStep; -static int redefineNumber; -static jint newClassSize; -static unsigned char* newClassBytes; static jthread testedThread; static jclass testClass; -char chbuffer[255]; -const char* getThreadName(JNIEnv* jni_env, jthread thread); +// callbackException (isCatch == false) and callbackExceptionCatch (isCatch == true) handler +void handleException(bool isCatch, + jvmtiEnv* jvmti_env, JNIEnv* jni_env, jthread thread, + jmethodID method, jlocation location, + jobject exception); + +const char* getThreadName(jvmtiEnv* jvmti_env, JNIEnv* jni_env, jthread thread); const char* getClassName(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jobject object); -int readNewBytecode(jvmtiEnv* jvmti); +int readNewBytecode(jvmtiEnv* jvmti, jint *newClassSize, unsigned char* *newClassBytes); int getLocalVariableValue(jvmtiEnv *jvmti_env, jthread thread, jmethodID method); /* ============================================================================= */ @@ -99,17 +101,19 @@ void disableEvent(jvmtiEnv *jvmti_env, jvmtiEvent event, jthread thread) { void redefineClass(jvmtiEnv *jvmti_env, jclass klass) { jvmtiClassDefinition classDef; - char *className; + jint newClassSize; + unsigned char* newClassBytes; if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, NULL))) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_VERIFY(readNewBytecode(jvmti_env))) { + if (!NSK_VERIFY(readNewBytecode(jvmti_env, &newClassSize, &newClassBytes))) { NSK_COMPLAIN0("TEST FAILED: new bytecode could not be read\n"); nsk_jvmti_setFailStatus(); + jvmti_env->Deallocate((unsigned char*)className); return; } @@ -121,12 +125,14 @@ void redefineClass(jvmtiEnv *jvmti_env, jclass klass) { if (!NSK_JVMTI_VERIFY(jvmti_env->RedefineClasses(1, &classDef))) { NSK_COMPLAIN1("TEST FAILED: while redefining class %s\n", className); nsk_jvmti_setFailStatus(); - return; } if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)className))) { nsk_jvmti_setFailStatus(); } + if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate(newClassBytes))) { + nsk_jvmti_setFailStatus(); + } } @@ -136,7 +142,6 @@ void redefineClass(jvmtiEnv *jvmti_env, jclass klass) { static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { - redefineNumber = 1; jni = agentJNI; NSK_DISPLAY0("Waiting for debuggee to become ready\n"); @@ -144,7 +149,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { return; testStep = 1; - NSK_DISPLAY0("\n\n>>>> Debugge started, waiting for class loading \n"); + NSK_DISPLAY0(">>>> Debugge started, waiting for class loading \n"); if (!nsk_jvmti_resumeSync()) return; @@ -183,9 +188,8 @@ callbackClassLoad(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jclass klass) { char *className; - char *generic; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, &generic))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, NULL))) { nsk_jvmti_setFailStatus(); return; } @@ -193,19 +197,13 @@ callbackClassLoad(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, if (strcmp(className, EXPECTED_CLASS_SIGN) == 0) { - NSK_DISPLAY1("\n\n>>>> Class loaded: %s", className); - NSK_DISPLAY0(", activating breakpoint\n"); + NSK_DISPLAY1(">>>> Class loaded: %s, activating breakpoint\n", className); setBreakPoint(jvmti_env, jni_env, klass); } if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)className))) { nsk_jvmti_setFailStatus(); } - - if (generic != NULL) - if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)generic))) { - nsk_jvmti_setFailStatus(); - } } /* ============================================================================= */ @@ -218,7 +216,7 @@ JNIEXPORT void JNICALL callbackBreakpoint(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID method, jlocation location) { - NSK_DISPLAY0("\n\n>>>>Breakpoint fired, enabling SINGLE_STEP\n"); + NSK_DISPLAY0(">>>>Breakpoint fired, enabling SINGLE_STEP\n"); enableEvent(jvmti_env, JVMTI_EVENT_SINGLE_STEP, thread); } @@ -268,7 +266,7 @@ callbackSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, case 2: - NSK_DISPLAY1("\n\n>>>> Checking if redefined method is not obsolete\n", testStep); + NSK_DISPLAY1(">>>> Checking if redefined method is not obsolete\n", testStep); if (!NSK_JVMTI_VERIFY(jvmti->IsMethodObsolete(method, &is_obsolete))) { NSK_COMPLAIN0("TEST FAILED: unable to check method to be obsolete\n"); @@ -285,7 +283,7 @@ callbackSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, case 3: - NSK_DISPLAY1("\n\n>>>> Popping the currently executing frame\n", testStep); + NSK_DISPLAY1(">>>> Popping the currently executing frame\n", testStep); testStep++; setCurrentStep(jni_env, testStep); @@ -294,7 +292,7 @@ callbackSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, case 5: if (value < 10) { - NSK_DISPLAY1("\n\n>>>> Disabling single step\n", testStep); + NSK_DISPLAY1(">>>> Disabling single step\n", testStep); disableEvent(jvmti_env, JVMTI_EVENT_SINGLE_STEP, thread); setCurrentStep(jni_env, testStep); } @@ -304,7 +302,7 @@ callbackSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, } if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) declaringClassName))) { - NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n"); + NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to declaringClassName\n\n"); } } @@ -326,24 +324,7 @@ callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID method, jlocation location, jobject exception, jmethodID catch_method, jlocation catch_location) { - const char *className; - - className = getClassName(jvmti_env, jni_env, exception); - - if (strcmp(EXPECTED_CLASS_SIGN, className) == 0) { - jclass klass; - - NSK_DISPLAY2("\n\n>>>> Exception %s in thread - %s\n", - className, getThreadName(jni_env, thread)); - - testStep++; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { - nsk_jvmti_setFailStatus(); - return; - } - - redefineClass(jvmti_env, klass); - } + handleException(false, jvmti_env, jni_env, thread, method, location, exception); } /* ============================================================================= */ @@ -357,15 +338,27 @@ callbackExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID method, jlocation location, jobject exception) { - const char *className; + handleException(true, jvmti_env, jni_env, thread, method, location, exception); +} + +/* ============================================================================= */ - className = getClassName(jvmti_env, jni_env, exception); +void handleException(bool isCatch, + jvmtiEnv* jvmti_env, JNIEnv* jni_env, jthread thread, + jmethodID method, jlocation location, + jobject exception) { + const char* className = getClassName(jvmti_env, jni_env, exception); - if (strcmp(EXPECTED_CLASS_SIGN, className) == 0) { + if (className != NULL && strcmp(EXPECTED_CLASS_SIGN, className) == 0) { jclass klass; - NSK_DISPLAY2("\n\n>>>> Caught exception %s in thread - %s\n", - className, getThreadName(jni_env, thread)); + const char* threadName = getThreadName(jvmti_env, jni_env, thread); + NSK_DISPLAY3(">>>> %s %s in thread - %s\n", isCatch ? "Caught exception" : "Exception", + className, threadName != NULL ? threadName : "NULL"); + jvmti->Deallocate((unsigned char*)className); + if (threadName != NULL) { + jvmti->Deallocate((unsigned char*)threadName); + } testStep++; if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { @@ -375,11 +368,11 @@ callbackExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, redefineClass(jvmti_env, klass); } + } -/* ============================================================================= */ -int readNewBytecode(jvmtiEnv* jvmti) { +int readNewBytecode(jvmtiEnv* jvmti, jint *newClassSize, unsigned char* *newClassBytes) { char filename[256]; FILE *bytecode; @@ -405,17 +398,19 @@ int readNewBytecode(jvmtiEnv* jvmti) { } fseek(bytecode, 0, SEEK_END); - newClassSize = ftell(bytecode); + *newClassSize = ftell(bytecode); rewind(bytecode); - if (!NSK_JVMTI_VERIFY(jvmti->Allocate(newClassSize, &newClassBytes))) { + if (!NSK_JVMTI_VERIFY(jvmti->Allocate(*newClassSize, newClassBytes))) { NSK_COMPLAIN0("buffer couldn't be allocated\n"); return NSK_FALSE; } - read_bytes = (jint) fread(newClassBytes, 1, newClassSize, bytecode); + read_bytes = (jint) fread(*newClassBytes, 1, *newClassSize, bytecode); fclose(bytecode); - if (read_bytes != newClassSize) { + if (read_bytes != *newClassSize) { NSK_COMPLAIN0("TEST FAILED: error reading file\n"); + jvmti->Deallocate(*newClassBytes); + *newClassBytes = NULL; return NSK_FALSE; } @@ -424,34 +419,41 @@ int readNewBytecode(jvmtiEnv* jvmti) { /* ============================================================================= */ -const char* getThreadName(JNIEnv* jni_env, jthread thread) { +const char* getThreadName(jvmtiEnv* jvmti_env, JNIEnv* jni_env, jthread thread) { jmethodID methodID; jclass klass; jstring jthreadName; + jsize jthreadNameLen; + unsigned char *result = NULL; const char *threadName; - strcpy(chbuffer, ""); - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(thread)) != NULL)) { nsk_jvmti_setFailStatus(); - return chbuffer; + return NULL; } if (!NSK_JNI_VERIFY(jni_env, (methodID = jni_env->GetMethodID(klass, "getName", "()Ljava/lang/String;")) != NULL)) { nsk_jvmti_setFailStatus(); - return chbuffer; + return NULL; } jthreadName = (jstring) jni_env->CallObjectMethod(thread, methodID); + jthreadNameLen = jni_env->GetStringUTFLength(jthreadName); + + if (!NSK_JVMTI_VERIFY(jvmti_env->Allocate(jthreadNameLen + 1, &result))) { + NSK_COMPLAIN0("buffer couldn't be allocated\n"); + return NULL; + } + threadName = jni_env->GetStringUTFChars(jthreadName, 0); - strcpy(chbuffer, threadName); + memcpy(result, threadName, jthreadNameLen + 1); jni_env->ReleaseStringUTFChars(jthreadName, threadName); - return chbuffer; + return (char*)result; } /* ============================================================================= */ @@ -459,33 +461,19 @@ const char* getThreadName(JNIEnv* jni_env, jthread thread) { const char* getClassName(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jobject object) { char *className; - char *generic; jclass klass; - strcpy(chbuffer, ""); - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(object)) != NULL)) { nsk_jvmti_setFailStatus(); - return chbuffer; - } - - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, &generic))) { - nsk_jvmti_setFailStatus(); - return chbuffer; + return NULL; } - strcpy(chbuffer, className); - - if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)className))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, NULL))) { nsk_jvmti_setFailStatus(); + return NULL; } - if (generic != NULL) - if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)generic))) { - nsk_jvmti_setFailStatus(); - } - - return chbuffer; + return className; } /* ============================================================================= */ @@ -548,6 +536,10 @@ Java_nsk_jvmti_scenarios_hotswap_HS201_hs201t002_setThread(JNIEnv *env, if (!NSK_JNI_VERIFY(env, (testedThread = env->NewGlobalRef(thread)) != NULL)) nsk_jvmti_setFailStatus(); + enableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD, testedThread); + enableEvent(jvmti, JVMTI_EVENT_BREAKPOINT, testedThread); + enableEvent(jvmti, JVMTI_EVENT_EXCEPTION, testedThread); + enableEvent(jvmti, JVMTI_EVENT_EXCEPTION_CATCH, testedThread); } /* ============================================================================= */ @@ -667,11 +659,6 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("Enable events\n"); - enableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD, testedThread); - enableEvent(jvmti, JVMTI_EVENT_BREAKPOINT, testedThread); - enableEvent(jvmti, JVMTI_EVENT_EXCEPTION, testedThread); - enableEvent(jvmti, JVMTI_EVENT_EXCEPTION_CATCH, testedThread); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) return JNI_ERR; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/newclass/hs201t002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/newclass/hs201t002a.java index 3d5a7b94694..f5d3d83e9c7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/newclass/hs201t002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/newclass/hs201t002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2022, 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 @@ -26,6 +26,7 @@ public class hs201t002a extends Exception { public hs201t002a () { + System.out.println("Current step: " + hs201t002.currentStep); // Avoid calling classloader to find hs201t002 in doInit() doInit(); }