8341798: Fix ExceptionOccurred in jdk.jdwp.agent
Reviewed-by: dholmes, cjplummer
This commit is contained in:
parent
825ceb16b2
commit
714472d8a5
src/jdk.jdwp.agent/share/native/libjdwp
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
@ -215,7 +215,7 @@ writeObjectComponents(JNIEnv *env, PacketOutputStream *out,
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
component = JNI_FUNC_PTR(env,GetObjectArrayElement)(env, array, index + i);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
/* cleared by caller */
|
||||
break;
|
||||
}
|
||||
@ -280,7 +280,7 @@ getValues(PacketInputStream *in, PacketOutputStream *out)
|
||||
|
||||
} END_WITH_LOCAL_REFS(env);
|
||||
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
outStream_setError(out, JDWP_ERROR(INTERNAL));
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
}
|
||||
@ -470,7 +470,7 @@ readObjectComponents(JNIEnv *env, PacketInputStream *in,
|
||||
jobject object = inStream_readObjectRef(env, in);
|
||||
|
||||
JNI_FUNC_PTR(env,SetObjectArrayElement)(env, array, index + i, object);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
/* caller will clear */
|
||||
break;
|
||||
}
|
||||
@ -529,7 +529,7 @@ setValues(PacketInputStream *in, PacketOutputStream *out)
|
||||
}
|
||||
} END_WITH_LOCAL_REFS(env);
|
||||
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
/*
|
||||
* TO DO: Check exception type
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
@ -124,7 +124,7 @@ writeNewObjectArray(JNIEnv *env, PacketOutputStream *out,
|
||||
} else {
|
||||
|
||||
array = JNI_FUNC_PTR(env,NewObjectArray)(env, size, componentClass, 0);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
array = NULL;
|
||||
}
|
||||
@ -188,7 +188,7 @@ writeNewPrimitiveArray(JNIEnv *env, PacketOutputStream *out,
|
||||
break;
|
||||
}
|
||||
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
array = NULL;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
@ -64,7 +64,7 @@ readStaticFieldValue(JNIEnv *env, PacketInputStream *in, jclass clazz,
|
||||
if (isReferenceTag(typeKey)) {
|
||||
value.l = inStream_readObjectRef(env, in);
|
||||
JNI_FUNC_PTR(env,SetStaticObjectField)(env, clazz, field, value.l);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
return JDWP_ERROR(INTERNAL);
|
||||
}
|
||||
return JDWP_ERROR(NONE);
|
||||
@ -112,7 +112,7 @@ readStaticFieldValue(JNIEnv *env, PacketInputStream *in, jclass clazz,
|
||||
break;
|
||||
}
|
||||
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
return JDWP_ERROR(INTERNAL);
|
||||
}
|
||||
return JDWP_ERROR(NONE);
|
||||
|
@ -76,7 +76,7 @@ readFieldValue(JNIEnv *env, PacketInputStream *in, jclass clazz,
|
||||
if (isReferenceTag(typeKey)) {
|
||||
value.l = inStream_readObjectRef(env, in);
|
||||
JNI_FUNC_PTR(env,SetObjectField)(env, object, field, value.l);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
return AGENT_ERROR_JNI_EXCEPTION;
|
||||
}
|
||||
return JVMTI_ERROR_NONE;
|
||||
@ -123,7 +123,7 @@ readFieldValue(JNIEnv *env, PacketInputStream *in, jclass clazz,
|
||||
break;
|
||||
}
|
||||
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
return AGENT_ERROR_JNI_EXCEPTION;
|
||||
}
|
||||
return JVMTI_ERROR_NONE;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
@ -714,7 +714,7 @@ createString(PacketInputStream *in, PacketOutputStream *out)
|
||||
jstring string;
|
||||
|
||||
string = JNI_FUNC_PTR(env,NewStringUTF)(env, cstring);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
outStream_setError(out, JDWP_ERROR(OUT_OF_MEMORY));
|
||||
} else {
|
||||
(void)outStream_writeObjectRef(env, out, string);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
@ -890,7 +890,7 @@ saveEventInfoRefs(JNIEnv *env, EventInfo *evinfo)
|
||||
break;
|
||||
}
|
||||
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
EXIT_ERROR(AGENT_ERROR_INVALID_EVENT_TYPE,"ExceptionOccurred");
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ findClass(JNIEnv *env, const char * name)
|
||||
ERROR_MESSAGE(("JDWP Can't find class %s", name));
|
||||
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
|
||||
}
|
||||
if ( JNI_FUNC_PTR(env,ExceptionOccurred)(env) ) {
|
||||
if ( JNI_FUNC_PTR(env,ExceptionCheck)(env) ) {
|
||||
ERROR_MESSAGE(("JDWP Exception occurred finding class %s", name));
|
||||
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
|
||||
}
|
||||
@ -135,7 +135,7 @@ getMethod(JNIEnv *env, jclass clazz, const char * name, const char *signature)
|
||||
name, signature));
|
||||
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
|
||||
}
|
||||
if ( JNI_FUNC_PTR(env,ExceptionOccurred)(env) ) {
|
||||
if ( JNI_FUNC_PTR(env,ExceptionCheck)(env) ) {
|
||||
ERROR_MESSAGE(("JDWP Exception occurred finding method %s with signature %s",
|
||||
name, signature));
|
||||
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
|
||||
@ -166,7 +166,7 @@ getStaticMethod(JNIEnv *env, jclass clazz, const char * name, const char *signat
|
||||
name, signature));
|
||||
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
|
||||
}
|
||||
if ( JNI_FUNC_PTR(env,ExceptionOccurred)(env) ) {
|
||||
if ( JNI_FUNC_PTR(env,ExceptionCheck)(env) ) {
|
||||
ERROR_MESSAGE(("JDWP Exception occurred finding method %s with signature %s",
|
||||
name, signature));
|
||||
EXIT_ERROR(AGENT_ERROR_NULL_POINTER,NULL);
|
||||
@ -266,7 +266,7 @@ util_initialize(JNIEnv *env)
|
||||
(env, "jdk/internal/vm/VMSupport");
|
||||
if (localVMSupportClass == NULL) {
|
||||
gdata->agent_properties = NULL;
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
}
|
||||
} else {
|
||||
@ -276,7 +276,7 @@ util_initialize(JNIEnv *env)
|
||||
localAgentProperties =
|
||||
JNI_FUNC_PTR(env,CallStaticObjectMethod)
|
||||
(env, localVMSupportClass, getAgentProperties);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
EXIT_ERROR(AGENT_ERROR_INTERNAL,
|
||||
"Exception occurred calling VMSupport.getAgentProperties");
|
||||
@ -855,7 +855,7 @@ spawnNewThread(jvmtiStartFunction func, void *arg, char *name)
|
||||
jstring nameString;
|
||||
|
||||
nameString = JNI_FUNC_PTR(env,NewStringUTF)(env, name);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
error = AGENT_ERROR_OUT_OF_MEMORY;
|
||||
goto err;
|
||||
@ -864,7 +864,7 @@ spawnNewThread(jvmtiStartFunction func, void *arg, char *name)
|
||||
thread = JNI_FUNC_PTR(env,NewObject)
|
||||
(env, gdata->threadClass, gdata->threadConstructor,
|
||||
gdata->systemThreadGroup, nameString);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
error = AGENT_ERROR_OUT_OF_MEMORY;
|
||||
goto err;
|
||||
@ -875,7 +875,7 @@ spawnNewThread(jvmtiStartFunction func, void *arg, char *name)
|
||||
*/
|
||||
JNI_FUNC_PTR(env,CallVoidMethod)
|
||||
(env, thread, gdata->threadSetDaemon, JNI_TRUE);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
error = AGENT_ERROR_JNI_EXCEPTION;
|
||||
goto err;
|
||||
@ -1593,14 +1593,14 @@ getPropertyValue(JNIEnv *env, char *propertyName)
|
||||
|
||||
/* Create new String object to hold the property name */
|
||||
nameString = JNI_FUNC_PTR(env,NewStringUTF)(env, propertyName);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
/* NULL will be returned below */
|
||||
} else {
|
||||
/* Call valueString = System.getProperty(nameString) */
|
||||
valueString = JNI_FUNC_PTR(env,CallStaticObjectMethod)
|
||||
(env, gdata->systemClass, gdata->systemGetProperty, nameString);
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
valueString = NULL;
|
||||
}
|
||||
@ -1647,7 +1647,7 @@ setAgentPropertyValue(JNIEnv *env, char *propertyName, char* propertyValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
|
||||
if (JNI_FUNC_PTR(env,ExceptionCheck)(env)) {
|
||||
JNI_FUNC_PTR(env,ExceptionClear)(env);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user