Add InvocationTargetException to Wellknownclasses
To simplify reflection code and eliminate a possible infinite loop
issue if encoding a jmethodID takes memory I added
j.l.r.InvocationTargetException and its constructor to
WellKnownClasses.
Test: ./test.py --host
Bug: 134162467
Change-Id: I77d3905e8e738820c9451decb88ac39df6fcefa7
diff --git a/runtime/reflection.cc b/runtime/reflection.cc
index 0dbec85..edd92da 100644
--- a/runtime/reflection.cc
+++ b/runtime/reflection.cc
@@ -497,14 +497,10 @@
// If we get another exception when we are trying to wrap, then just use that instead.
ScopedLocalRef<jthrowable> th(soa.Env(), soa.Env()->ExceptionOccurred());
soa.Self()->ClearException();
- jclass exception_class = soa.Env()->FindClass("java/lang/reflect/InvocationTargetException");
- if (exception_class == nullptr) {
- soa.Self()->AssertPendingException();
- return false;
- }
- jmethodID mid = soa.Env()->GetMethodID(exception_class, "<init>", "(Ljava/lang/Throwable;)V");
- CHECK(mid != nullptr);
- jobject exception_instance = soa.Env()->NewObject(exception_class, mid, th.get());
+ jobject exception_instance =
+ soa.Env()->NewObject(WellKnownClasses::java_lang_reflect_InvocationTargetException,
+ WellKnownClasses::java_lang_reflect_InvocationTargetException_init,
+ th.get());
if (exception_instance == nullptr) {
soa.Self()->AssertPendingException();
return false;