From 7b97aebac851b345c7733d56ffe0fedf66010dbb Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 1 Dec 2022 16:17:47 +0000 Subject: Remove class root duplicates from well known classes. And get well known exception classes as declaring classes of their constructors. Also change function `ThreadForEnv()` to `Thread::ForEnv()` and use it where appropriate, mostly in code added recently while cleaning up well-known methods. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I2ededa429863a6cddbcbb879a223277fd6245557 --- runtime/class_loader_context_test.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'runtime/class_loader_context_test.cc') diff --git a/runtime/class_loader_context_test.cc b/runtime/class_loader_context_test.cc index d89c5b6b33..ce9780a74e 100644 --- a/runtime/class_loader_context_test.cc +++ b/runtime/class_loader_context_test.cc @@ -24,6 +24,7 @@ #include "android-base/stringprintf.h" #include "android-base/strings.h" #include "art_field-inl.h" +#include "art_method-alloc-inl.h" #include "base/dchecked_vector.h" #include "base/stl_util.h" #include "class_linker.h" @@ -1362,13 +1363,14 @@ TEST_F(ClassLoaderContextTest, EncodeContextsForSingleDex) { static jobject CreateForeignClassLoader() { ScopedObjectAccess soa(Thread::Current()); - JNIEnv* env = soa.Env(); // We cannot instantiate a ClassLoader directly, so instead we allocate an Object to represent // our foreign ClassLoader (this works because the runtime does proper instanceof checks before // operating on this object. - jmethodID ctor = env->GetMethodID(WellKnownClasses::java_lang_Object, "", "()V"); - return env->NewObject(WellKnownClasses::java_lang_Object, ctor); + ArtMethod* ctor = + GetClassRoot()->FindClassMethod("", "()V", kRuntimePointerSize); + CHECK(ctor != nullptr); + return soa.AddLocalReference(ctor->NewObject<>(soa.Self())); } TEST_F(ClassLoaderContextTest, EncodeContextsForUnsupportedBase) { -- cgit v1.2.3-59-g8ed1b