Skip to content

Commit 714472d

Browse files
author
Justin Lu
committed
8341798: Fix ExceptionOccurred in jdk.jdwp.agent
Reviewed-by: dholmes, cjplummer
1 parent 825ceb1 commit 714472d

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

src/jdk.jdwp.agent/share/native/libjdwp/ArrayReferenceImpl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -215,7 +215,7 @@ writeObjectComponents(JNIEnv *env, PacketOutputStream *out,
215215

216216
for (i = 0; i < length; i++) {
217217
component = JNI_FUNC_PTR(env,GetObjectArrayElement)(env, array, index + i);
218-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
218+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
219219
/* cleared by caller */
220220
break;
221221
}
@@ -280,7 +280,7 @@ getValues(PacketInputStream *in, PacketOutputStream *out)
280280

281281
} END_WITH_LOCAL_REFS(env);
282282

283-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
283+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
284284
outStream_setError(out, JDWP_ERROR(INTERNAL));
285285
JNI_FUNC_PTR(env,ExceptionClear)(env);
286286
}
@@ -470,7 +470,7 @@ readObjectComponents(JNIEnv *env, PacketInputStream *in,
470470
jobject object = inStream_readObjectRef(env, in);
471471

472472
JNI_FUNC_PTR(env,SetObjectArrayElement)(env, array, index + i, object);
473-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
473+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
474474
/* caller will clear */
475475
break;
476476
}
@@ -529,7 +529,7 @@ setValues(PacketInputStream *in, PacketOutputStream *out)
529529
}
530530
} END_WITH_LOCAL_REFS(env);
531531

532-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
532+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
533533
/*
534534
* TO DO: Check exception type
535535
*/

src/jdk.jdwp.agent/share/native/libjdwp/ArrayTypeImpl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -124,7 +124,7 @@ writeNewObjectArray(JNIEnv *env, PacketOutputStream *out,
124124
} else {
125125

126126
array = JNI_FUNC_PTR(env,NewObjectArray)(env, size, componentClass, 0);
127-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
127+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
128128
JNI_FUNC_PTR(env,ExceptionClear)(env);
129129
array = NULL;
130130
}
@@ -188,7 +188,7 @@ writeNewPrimitiveArray(JNIEnv *env, PacketOutputStream *out,
188188
break;
189189
}
190190

191-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
191+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
192192
JNI_FUNC_PTR(env,ExceptionClear)(env);
193193
array = NULL;
194194
}

src/jdk.jdwp.agent/share/native/libjdwp/ClassTypeImpl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,7 @@ readStaticFieldValue(JNIEnv *env, PacketInputStream *in, jclass clazz,
6464
if (isReferenceTag(typeKey)) {
6565
value.l = inStream_readObjectRef(env, in);
6666
JNI_FUNC_PTR(env,SetStaticObjectField)(env, clazz, field, value.l);
67-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
67+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
6868
return JDWP_ERROR(INTERNAL);
6969
}
7070
return JDWP_ERROR(NONE);
@@ -112,7 +112,7 @@ readStaticFieldValue(JNIEnv *env, PacketInputStream *in, jclass clazz,
112112
break;
113113
}
114114

115-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
115+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
116116
return JDWP_ERROR(INTERNAL);
117117
}
118118
return JDWP_ERROR(NONE);

src/jdk.jdwp.agent/share/native/libjdwp/ObjectReferenceImpl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ readFieldValue(JNIEnv *env, PacketInputStream *in, jclass clazz,
7676
if (isReferenceTag(typeKey)) {
7777
value.l = inStream_readObjectRef(env, in);
7878
JNI_FUNC_PTR(env,SetObjectField)(env, object, field, value.l);
79-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
79+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
8080
return AGENT_ERROR_JNI_EXCEPTION;
8181
}
8282
return JVMTI_ERROR_NONE;
@@ -123,7 +123,7 @@ readFieldValue(JNIEnv *env, PacketInputStream *in, jclass clazz,
123123
break;
124124
}
125125

126-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
126+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
127127
return AGENT_ERROR_JNI_EXCEPTION;
128128
}
129129
return JVMTI_ERROR_NONE;

src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -714,7 +714,7 @@ createString(PacketInputStream *in, PacketOutputStream *out)
714714
jstring string;
715715

716716
string = JNI_FUNC_PTR(env,NewStringUTF)(env, cstring);
717-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
717+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
718718
outStream_setError(out, JDWP_ERROR(OUT_OF_MEMORY));
719719
} else {
720720
(void)outStream_writeObjectRef(env, out, string);

src/jdk.jdwp.agent/share/native/libjdwp/eventHelper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -890,7 +890,7 @@ saveEventInfoRefs(JNIEnv *env, EventInfo *evinfo)
890890
break;
891891
}
892892

893-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
893+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
894894
EXIT_ERROR(AGENT_ERROR_INVALID_EVENT_TYPE,"ExceptionOccurred");
895895
}
896896
}

src/jdk.jdwp.agent/share/native/libjdwp/util.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ findClass(JNIEnv *env, const char * name)
105105
ERROR_MESSAGE(("JDWP Can't find class %s", name));
106106
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
107107
}
108-
if ( JNI_FUNC_PTR(env,ExceptionOccurred)(env) ) {
108+
if ( JNI_FUNC_PTR(env,ExceptionCheck)(env) ) {
109109
ERROR_MESSAGE(("JDWP Exception occurred finding class %s", name));
110110
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
111111
}
@@ -135,7 +135,7 @@ getMethod(JNIEnv *env, jclass clazz, const char * name, const char *signature)
135135
name, signature));
136136
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
137137
}
138-
if ( JNI_FUNC_PTR(env,ExceptionOccurred)(env) ) {
138+
if ( JNI_FUNC_PTR(env,ExceptionCheck)(env) ) {
139139
ERROR_MESSAGE(("JDWP Exception occurred finding method %s with signature %s",
140140
name, signature));
141141
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
@@ -166,7 +166,7 @@ getStaticMethod(JNIEnv *env, jclass clazz, const char * name, const char *signat
166166
name, signature));
167167
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
168168
}
169-
if ( JNI_FUNC_PTR(env,ExceptionOccurred)(env) ) {
169+
if ( JNI_FUNC_PTR(env,ExceptionCheck)(env) ) {
170170
ERROR_MESSAGE(("JDWP Exception occurred finding method %s with signature %s",
171171
name, signature));
172172
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
@@ -266,7 +266,7 @@ util_initialize(JNIEnv *env)
266266
(env, "jdk/internal/vm/VMSupport");
267267
if (localVMSupportClass == NULL) {
268268
gdata->agent_properties = NULL;
269-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
269+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
270270
JNI_FUNC_PTR(env,ExceptionClear)(env);
271271
}
272272
} else {
@@ -276,7 +276,7 @@ util_initialize(JNIEnv *env)
276276
localAgentProperties =
277277
JNI_FUNC_PTR(env,CallStaticObjectMethod)
278278
(env, localVMSupportClass, getAgentProperties);
279-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
279+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
280280
JNI_FUNC_PTR(env,ExceptionClear)(env);
281281
EXIT_ERROR(AGENT_ERROR_INTERNAL,
282282
"Exception occurred calling VMSupport.getAgentProperties");
@@ -855,7 +855,7 @@ spawnNewThread(jvmtiStartFunction func, void *arg, char *name)
855855
jstring nameString;
856856

857857
nameString = JNI_FUNC_PTR(env,NewStringUTF)(env, name);
858-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
858+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
859859
JNI_FUNC_PTR(env,ExceptionClear)(env);
860860
error = AGENT_ERROR_OUT_OF_MEMORY;
861861
goto err;
@@ -864,7 +864,7 @@ spawnNewThread(jvmtiStartFunction func, void *arg, char *name)
864864
thread = JNI_FUNC_PTR(env,NewObject)
865865
(env, gdata->threadClass, gdata->threadConstructor,
866866
gdata->systemThreadGroup, nameString);
867-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
867+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
868868
JNI_FUNC_PTR(env,ExceptionClear)(env);
869869
error = AGENT_ERROR_OUT_OF_MEMORY;
870870
goto err;
@@ -875,7 +875,7 @@ spawnNewThread(jvmtiStartFunction func, void *arg, char *name)
875875
*/
876876
JNI_FUNC_PTR(env,CallVoidMethod)
877877
(env, thread, gdata->threadSetDaemon, JNI_TRUE);
878-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
878+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
879879
JNI_FUNC_PTR(env,ExceptionClear)(env);
880880
error = AGENT_ERROR_JNI_EXCEPTION;
881881
goto err;
@@ -1593,14 +1593,14 @@ getPropertyValue(JNIEnv *env, char *propertyName)
15931593

15941594
/* Create new String object to hold the property name */
15951595
nameString = JNI_FUNC_PTR(env,NewStringUTF)(env, propertyName);
1596-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
1596+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
15971597
JNI_FUNC_PTR(env,ExceptionClear)(env);
15981598
/* NULL will be returned below */
15991599
} else {
16001600
/* Call valueString = System.getProperty(nameString) */
16011601
valueString = JNI_FUNC_PTR(env,CallStaticObjectMethod)
16021602
(env, gdata->systemClass, gdata->systemGetProperty, nameString);
1603-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
1603+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
16041604
JNI_FUNC_PTR(env,ExceptionClear)(env);
16051605
valueString = NULL;
16061606
}
@@ -1647,7 +1647,7 @@ setAgentPropertyValue(JNIEnv *env, char *propertyName, char* propertyValue)
16471647
}
16481648
}
16491649
}
1650-
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
1650+
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
16511651
JNI_FUNC_PTR(env,ExceptionClear)(env);
16521652
}
16531653
}

0 commit comments

Comments
 (0)