From f11cd290e7e1a747c53916f7f6b904a73136c741 Mon Sep 17 00:00:00 2001 From: Przemyslaw Szczepaniak Date: Wed, 17 Aug 2016 17:46:38 +0100 Subject: [PATCH] Track libcore java.lang.reflect.Proxy update Test: make -j 32 & booted device & m test-art-host Bug: 28666126 Change-Id: I6e7d75fd904e9b130925756ef1ff1122c25ab245 --- runtime/class_linker.cc | 5 +++-- runtime/well_known_classes.cc | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 5b8d4e42a..8586b783a 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -4280,9 +4280,10 @@ std::string ClassLinker::GetDescriptorForProxy(ObjPtr proxy_class void ClassLinker::CreateProxyConstructor(Handle klass, ArtMethod* out) { // Create constructor for Proxy that must initialize the method. - CHECK_EQ(GetClassRoot(kJavaLangReflectProxy)->NumDirectMethods(), 18u); + CHECK_EQ(GetClassRoot(kJavaLangReflectProxy)->NumDirectMethods(), 23u); + ArtMethod* proxy_constructor = GetClassRoot(kJavaLangReflectProxy)->GetDirectMethodUnchecked( - 2, image_pointer_size_); + 8, image_pointer_size_); DCHECK_EQ(std::string(proxy_constructor->GetName()), ""); // Ensure constructor is in dex cache so that we can use the dex cache to look up the overridden // constructor method. diff --git a/runtime/well_known_classes.cc b/runtime/well_known_classes.cc index 009170cb1..ae8d33177 100644 --- a/runtime/well_known_classes.cc +++ b/runtime/well_known_classes.cc @@ -328,7 +328,6 @@ void WellKnownClasses::Init(JNIEnv* env) { java_lang_ref_ReferenceQueue_add = CacheMethod(env, java_lang_ref_ReferenceQueue.get(), true, "add", "(Ljava/lang/ref/Reference;)V"); java_lang_reflect_Parameter_init = CacheMethod(env, java_lang_reflect_Parameter, false, "", "(Ljava/lang/String;ILjava/lang/reflect/Executable;I)V"); - java_lang_reflect_Proxy_invoke = CacheMethod(env, java_lang_reflect_Proxy, true, "invoke", "(Ljava/lang/reflect/Proxy;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;"); java_lang_Thread_dispatchUncaughtException = CacheMethod(env, java_lang_Thread, false, "dispatchUncaughtException", "(Ljava/lang/Throwable;)V"); java_lang_Thread_init = CacheMethod(env, java_lang_Thread, false, "", "(Ljava/lang/ThreadGroup;Ljava/lang/String;IZ)V"); java_lang_Thread_run = CacheMethod(env, java_lang_Thread, false, "run", "()V"); @@ -362,7 +361,6 @@ void WellKnownClasses::Init(JNIEnv* env) { java_lang_Throwable_stackState = CacheField(env, java_lang_Throwable, false, "backtrace", "Ljava/lang/Object;"); java_lang_Throwable_suppressedExceptions = CacheField(env, java_lang_Throwable, false, "suppressedExceptions", "Ljava/util/List;"); java_lang_reflect_Executable_artMethod = CacheField(env, java_lang_reflect_Executable, false, "artMethod", "J"); - java_lang_reflect_Proxy_h = CacheField(env, java_lang_reflect_Proxy, false, "h", "Ljava/lang/reflect/InvocationHandler;"); java_nio_DirectByteBuffer_capacity = CacheField(env, java_nio_DirectByteBuffer, false, "capacity", "I"); java_nio_DirectByteBuffer_effectiveDirectAddress = CacheField(env, java_nio_DirectByteBuffer, false, "address", "J"); java_util_ArrayList_array = CacheField(env, java_util_ArrayList, false, "elementData", "[Ljava/lang/Object;"); @@ -389,10 +387,20 @@ void WellKnownClasses::Init(JNIEnv* env) { void WellKnownClasses::LateInit(JNIEnv* env) { ScopedLocalRef java_lang_Runtime(env, env->FindClass("java/lang/Runtime")); + // CacheField and CacheMethod will initialize their classes. Classes below + // have clinit sections that call JNI methods. Late init is required + // to make sure these JNI methods are available. java_lang_Runtime_nativeLoad = CacheMethod(env, java_lang_Runtime.get(), true, "nativeLoad", "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;)" "Ljava/lang/String;"); + java_lang_reflect_Proxy_invoke = + CacheMethod(env, java_lang_reflect_Proxy, true, "invoke", + "(Ljava/lang/reflect/Proxy;Ljava/lang/reflect/Method;" + "[Ljava/lang/Object;)Ljava/lang/Object;"); + java_lang_reflect_Proxy_h = + CacheField(env, java_lang_reflect_Proxy, false, "h", + "Ljava/lang/reflect/InvocationHandler;"); } ObjPtr WellKnownClasses::ToClass(jclass global_jclass) { -- 2.11.0