diff --git a/test/hotspot/jtreg/ProblemList-Xcomp.txt b/test/hotspot/jtreg/ProblemList-Xcomp.txt index 2364d601cd7..9a52a731039 100644 --- a/test/hotspot/jtreg/ProblemList-Xcomp.txt +++ b/test/hotspot/jtreg/ProblemList-Xcomp.txt @@ -28,8 +28,6 @@ ############################################################################# vmTestbase/nsk/jvmti/AttachOnDemand/attach020/TestDescription.java 8287324 generic-all -vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java 8205957 generic-all -vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/TestDescription.java 8205957 linux-x64,windows-x64 vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/TestDescription.java 8245680 windows-x64 vmTestbase/vm/mlvm/mixed/stress/regression/b6969574/INDIFY_Test.java 8265295 linux-x64,windows-x64 diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java index b2af4412947..de99ad3686e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -48,3 +48,10 @@ * @run main/othervm/native -agentlib:setfldw001 nsk.jvmti.SetFieldAccessWatch.setfldw001 */ +/* + * @test id=logging + * + * @library /vmTestbase + * /test/lib + * @run main/othervm/native -agentlib:setfldw001 -XX:TraceJVMTI=ec+,+ioe,+s -Xlog:jvmti=trace:file=vm.%p.log nsk.jvmti.SetFieldAccessWatch.setfldw001 + */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/setfldw001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/setfldw001.cpp index 57286ce78a0..67d92df6dd2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/setfldw001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/setfldw001.cpp @@ -26,6 +26,7 @@ #include #include "jvmti.h" #include "agent_common.hpp" +#include "jvmti_common.hpp" #include "JVMTITools.hpp" extern "C" { @@ -114,6 +115,14 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *env, } fld_ind = (int)(fld_name[len - 1] - '0'); /* last digit is index in the array */ fields[fld_ind].thrown_fid = field; + + if (field == nullptr) { + fatal(env, "null field ID in FieldModification event."); + } + + LOG("Event: (Field %d) field ID expected: 0x%p, got: 0x%p\n", + fld_ind, fields[fld_ind].fid, field); + jvmti_env->Deallocate((unsigned char*) fld_name); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/TestDescription.java index 1decdae357d..d0cbdc288b4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -48,3 +48,10 @@ * @run main/othervm/native -agentlib:setfmodw001 nsk.jvmti.SetFieldModificationWatch.setfmodw001 */ +/* + * @test id=logging + * + * @library /vmTestbase + * /test/lib + * @run main/othervm/native -agentlib:setfmodw001 -XX:TraceJVMTI=ec+,+ioe,+s -Xlog:jvmti=trace:file=vm.%p.log nsk.jvmti.SetFieldModificationWatch.setfmodw001 + */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/setfmodw001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/setfmodw001.cpp index 28851bc6838..4e41aa285e3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/setfmodw001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/setfmodw001.cpp @@ -26,6 +26,7 @@ #include #include "jvmti.h" #include "agent_common.hpp" +#include "jvmti_common.hpp" #include "JVMTITools.hpp" extern "C" { @@ -108,6 +109,13 @@ void JNICALL FieldModification(jvmtiEnv *jvmti_env, JNIEnv *env, } fld_ind = (int)(fld_name[len - 1] - '0'); /* last digit is index in the array */ fields[fld_ind].thrown_fid = field; + + if (field == nullptr) { + fatal(env, "null field ID in FieldModification event."); + } + LOG("Event: (Field %d) field ID expected: 0x%p, got: 0x%p\n", + fld_ind, fields[fld_ind].fid, field); + jvmti_env->Deallocate((unsigned char*) fld_name); }