diff options
author | 2022-12-02 15:24:06 +0000 | |
---|---|---|
committer | 2022-12-02 15:24:06 +0000 | |
commit | 28280e94e9440522b6b127bc1c2c37932daf5bc4 (patch) | |
tree | 76fc15392508d29f0472f0979138f8bcb645b383 /runtime/class_linker.cc | |
parent | 4f188e20bee01915f152d702ff158a8fd4f16412 (diff) | |
parent | 7b97aebac851b345c7733d56ffe0fedf66010dbb (diff) |
Remove class root duplicates from well known classes. am: 7b97aebac8
Original change: https://android-review.googlesource.com/c/platform/art/+/2323316
Change-Id: If02af5af06cc62f228b209ce347fb88676d8be0e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r-- | runtime/class_linker.cc | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 3bb756f574..f94d791ffd 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -536,10 +536,9 @@ static void VlogClassInitializationFailure(Handle<mirror::Class> klass) static void WrapExceptionInInitializer(Handle<mirror::Class> klass) REQUIRES_SHARED(Locks::mutator_lock_) { Thread* self = Thread::Current(); - JNIEnv* env = self->GetJniEnv(); - ScopedLocalRef<jthrowable> cause(env, env->ExceptionOccurred()); - CHECK(cause.get() != nullptr); + ObjPtr<mirror::Throwable> cause = self->GetException(); + CHECK(cause != nullptr); // Boot classpath classes should not fail initialization. This is a consistency debug check. // This cannot in general be guaranteed, but in all likelihood leads to breakage down the line. @@ -554,12 +553,8 @@ static void WrapExceptionInInitializer(Handle<mirror::Class> klass) << self->GetException()->Dump(); } - env->ExceptionClear(); - bool is_error = env->IsInstanceOf(cause.get(), WellKnownClasses::java_lang_Error); - env->Throw(cause.get()); - // We only wrap non-Error exceptions; an Error can just be used as-is. - if (!is_error) { + if (!cause->IsError()) { self->ThrowNewWrappedException("Ljava/lang/ExceptionInInitializerError;", nullptr); } VlogClassInitializationFailure(klass); @@ -1132,14 +1127,6 @@ void ClassLinker::RunRootClinits(Thread* self) { // classes are always in the boot image, so this code is primarily intended // for running without boot image but may be needed for boot image if the // AOT-initialization fails due to introduction of new code to `<clinit>`. - jclass classes_to_initialize[] = { - // Initialize `StackOverflowError`. - WellKnownClasses::java_lang_StackOverflowError, - }; - auto* vm = down_cast<JNIEnvExt*>(self->GetJniEnv())->GetVm(); - for (jclass c : classes_to_initialize) { - EnsureRootInitialized(this, self, ObjPtr<mirror::Class>::DownCast(vm->DecodeGlobal(c))); - } ArtMethod* static_methods_of_classes_to_initialize[] = { // Initialize primitive boxing classes (avoid check at runtime). WellKnownClasses::java_lang_Boolean_valueOf, @@ -1150,6 +1137,8 @@ void ClassLinker::RunRootClinits(Thread* self) { WellKnownClasses::java_lang_Integer_valueOf, WellKnownClasses::java_lang_Long_valueOf, WellKnownClasses::java_lang_Short_valueOf, + // Initialize `StackOverflowError`. + WellKnownClasses::java_lang_StackOverflowError_init, // Ensure class loader classes are initialized (avoid check at runtime). // Superclass `ClassLoader` is a class root and already initialized above. // Superclass `BaseDexClassLoader` is initialized implicitly. |