mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
4505697: nsk/jdi/ExceptionEvent/_itself_/exevent006 and exevent008 tests fail with InvocationTargetException
Reviewed-by: dcubed, dholmes, sspitsyn
This commit is contained in:
parent
605e69a0dc
commit
2b75897176
5 changed files with 34 additions and 1 deletions
|
@ -49,6 +49,7 @@
|
||||||
#include "prims/jvmtiExport.hpp"
|
#include "prims/jvmtiExport.hpp"
|
||||||
#include "prims/jvmtiRedefineClassesTrace.hpp"
|
#include "prims/jvmtiRedefineClassesTrace.hpp"
|
||||||
#include "prims/jvmtiRedefineClasses.hpp"
|
#include "prims/jvmtiRedefineClasses.hpp"
|
||||||
|
#include "prims/jvmtiThreadState.hpp"
|
||||||
#include "prims/methodComparator.hpp"
|
#include "prims/methodComparator.hpp"
|
||||||
#include "runtime/fieldDescriptor.hpp"
|
#include "runtime/fieldDescriptor.hpp"
|
||||||
#include "runtime/handles.inline.hpp"
|
#include "runtime/handles.inline.hpp"
|
||||||
|
@ -862,10 +863,16 @@ void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) {
|
||||||
// Step 10 and 11
|
// Step 10 and 11
|
||||||
Handle e(THREAD, PENDING_EXCEPTION);
|
Handle e(THREAD, PENDING_EXCEPTION);
|
||||||
CLEAR_PENDING_EXCEPTION;
|
CLEAR_PENDING_EXCEPTION;
|
||||||
|
// JVMTI has already reported the pending exception
|
||||||
|
// JVMTI internal flag reset is needed in order to report ExceptionInInitializerError
|
||||||
|
JvmtiExport::clear_detected_exception((JavaThread*)THREAD);
|
||||||
{
|
{
|
||||||
EXCEPTION_MARK;
|
EXCEPTION_MARK;
|
||||||
this_oop->set_initialization_state_and_notify(initialization_error, THREAD);
|
this_oop->set_initialization_state_and_notify(initialization_error, THREAD);
|
||||||
CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, class initialization error is thrown below
|
CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, class initialization error is thrown below
|
||||||
|
// JVMTI has already reported the pending exception
|
||||||
|
// JVMTI internal flag reset is needed in order to report ExceptionInInitializerError
|
||||||
|
JvmtiExport::clear_detected_exception((JavaThread*)THREAD);
|
||||||
}
|
}
|
||||||
DTRACE_CLASSINIT_PROBE_WAIT(error, InstanceKlass::cast(this_oop()), -1,wait);
|
DTRACE_CLASSINIT_PROBE_WAIT(error, InstanceKlass::cast(this_oop()), -1,wait);
|
||||||
if (e->is_a(SystemDictionary::Error_klass())) {
|
if (e->is_a(SystemDictionary::Error_klass())) {
|
||||||
|
|
|
@ -1241,7 +1241,11 @@ JVM_ENTRY(jobject, JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, job
|
||||||
if (HAS_PENDING_EXCEPTION) {
|
if (HAS_PENDING_EXCEPTION) {
|
||||||
pending_exception = Handle(THREAD, PENDING_EXCEPTION);
|
pending_exception = Handle(THREAD, PENDING_EXCEPTION);
|
||||||
CLEAR_PENDING_EXCEPTION;
|
CLEAR_PENDING_EXCEPTION;
|
||||||
|
// JVMTI has already reported the pending exception
|
||||||
|
// JVMTI internal flag reset is needed in order to report PrivilegedActionException
|
||||||
|
if (THREAD->is_Java_thread()) {
|
||||||
|
JvmtiExport::clear_detected_exception((JavaThread*) THREAD);
|
||||||
|
}
|
||||||
if ( pending_exception->is_a(SystemDictionary::Exception_klass()) &&
|
if ( pending_exception->is_a(SystemDictionary::Exception_klass()) &&
|
||||||
!pending_exception->is_a(SystemDictionary::RuntimeException_klass())) {
|
!pending_exception->is_a(SystemDictionary::RuntimeException_klass())) {
|
||||||
// Throw a java.security.PrivilegedActionException(Exception e) exception
|
// Throw a java.security.PrivilegedActionException(Exception e) exception
|
||||||
|
|
|
@ -2161,6 +2161,15 @@ void JvmtiExport::cleanup_thread(JavaThread* thread) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JvmtiExport::clear_detected_exception(JavaThread* thread) {
|
||||||
|
assert(JavaThread::current() == thread, "thread is not current");
|
||||||
|
|
||||||
|
JvmtiThreadState* state = thread->jvmti_thread_state();
|
||||||
|
if (state != NULL) {
|
||||||
|
state->clear_exception_detected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void JvmtiExport::oops_do(OopClosure* f) {
|
void JvmtiExport::oops_do(OopClosure* f) {
|
||||||
JvmtiCurrentBreakpoints::oops_do(f);
|
JvmtiCurrentBreakpoints::oops_do(f);
|
||||||
JvmtiVMObjectAllocEventCollector::oops_do_for_all_threads(f);
|
JvmtiVMObjectAllocEventCollector::oops_do_for_all_threads(f);
|
||||||
|
|
|
@ -363,6 +363,7 @@ class JvmtiExport : public AllStatic {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanup_thread (JavaThread* thread) NOT_JVMTI_RETURN;
|
static void cleanup_thread (JavaThread* thread) NOT_JVMTI_RETURN;
|
||||||
|
static void clear_detected_exception (JavaThread* thread) NOT_JVMTI_RETURN;
|
||||||
|
|
||||||
static void oops_do(OopClosure* f) NOT_JVMTI_RETURN;
|
static void oops_do(OopClosure* f) NOT_JVMTI_RETURN;
|
||||||
static void weak_oops_do(BoolObjectClosure* b, OopClosure* f) NOT_JVMTI_RETURN;
|
static void weak_oops_do(BoolObjectClosure* b, OopClosure* f) NOT_JVMTI_RETURN;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "oops/objArrayKlass.hpp"
|
#include "oops/objArrayKlass.hpp"
|
||||||
#include "oops/objArrayOop.hpp"
|
#include "oops/objArrayOop.hpp"
|
||||||
#include "prims/jvm.h"
|
#include "prims/jvm.h"
|
||||||
|
#include "prims/jvmtiExport.hpp"
|
||||||
#include "runtime/arguments.hpp"
|
#include "runtime/arguments.hpp"
|
||||||
#include "runtime/handles.inline.hpp"
|
#include "runtime/handles.inline.hpp"
|
||||||
#include "runtime/javaCalls.hpp"
|
#include "runtime/javaCalls.hpp"
|
||||||
|
@ -941,6 +942,11 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method,
|
||||||
// Method resolution threw an exception; wrap it in an InvocationTargetException
|
// Method resolution threw an exception; wrap it in an InvocationTargetException
|
||||||
oop resolution_exception = PENDING_EXCEPTION;
|
oop resolution_exception = PENDING_EXCEPTION;
|
||||||
CLEAR_PENDING_EXCEPTION;
|
CLEAR_PENDING_EXCEPTION;
|
||||||
|
// JVMTI has already reported the pending exception
|
||||||
|
// JVMTI internal flag reset is needed in order to report InvocationTargetException
|
||||||
|
if (THREAD->is_Java_thread()) {
|
||||||
|
JvmtiExport::clear_detected_exception((JavaThread*) THREAD);
|
||||||
|
}
|
||||||
JavaCallArguments args(Handle(THREAD, resolution_exception));
|
JavaCallArguments args(Handle(THREAD, resolution_exception));
|
||||||
THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
|
THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
|
||||||
vmSymbols::throwable_void_signature(),
|
vmSymbols::throwable_void_signature(),
|
||||||
|
@ -1073,6 +1079,12 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method,
|
||||||
// Method threw an exception; wrap it in an InvocationTargetException
|
// Method threw an exception; wrap it in an InvocationTargetException
|
||||||
oop target_exception = PENDING_EXCEPTION;
|
oop target_exception = PENDING_EXCEPTION;
|
||||||
CLEAR_PENDING_EXCEPTION;
|
CLEAR_PENDING_EXCEPTION;
|
||||||
|
// JVMTI has already reported the pending exception
|
||||||
|
// JVMTI internal flag reset is needed in order to report InvocationTargetException
|
||||||
|
if (THREAD->is_Java_thread()) {
|
||||||
|
JvmtiExport::clear_detected_exception((JavaThread*) THREAD);
|
||||||
|
}
|
||||||
|
|
||||||
JavaCallArguments args(Handle(THREAD, target_exception));
|
JavaCallArguments args(Handle(THREAD, target_exception));
|
||||||
THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
|
THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
|
||||||
vmSymbols::throwable_void_signature(),
|
vmSymbols::throwable_void_signature(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue