diff options
author | 2022-12-01 16:17:47 +0000 | |
---|---|---|
committer | 2022-12-02 15:00:55 +0000 | |
commit | 7b97aebac851b345c7733d56ffe0fedf66010dbb (patch) | |
tree | b1be8f0d36642d4d27e3e73dd63f24ba67ed7352 /runtime/class_loader_context_test.cc | |
parent | 4c25ffc893541a4c3d5f6c077914633ca637406a (diff) |
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
Diffstat (limited to 'runtime/class_loader_context_test.cc')
-rw-r--r-- | runtime/class_loader_context_test.cc | 8 |
1 files changed, 5 insertions, 3 deletions
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, "<init>", "()V"); - return env->NewObject(WellKnownClasses::java_lang_Object, ctor); + ArtMethod* ctor = + GetClassRoot<mirror::Object>()->FindClassMethod("<init>", "()V", kRuntimePointerSize); + CHECK(ctor != nullptr); + return soa.AddLocalReference<jobject>(ctor->NewObject<>(soa.Self())); } TEST_F(ClassLoaderContextTest, EncodeContextsForUnsupportedBase) { |