diff options
| -rw-r--r-- | runtime/class_linker.cc | 2 | ||||
| -rw-r--r-- | runtime/native/java_lang_reflect_Constructor.cc | 15 |
2 files changed, 13 insertions, 4 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 6e7d8e54f1..035ba449a5 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -5216,7 +5216,7 @@ bool ClassLinker::LinkFields(Thread* self, Handle<mirror::Class> klass, bool is_ ArtField* field = &fields[i]; VLOG(class_linker) << "LinkFields: " << (is_static ? "static" : "instance") << " class=" << PrettyClass(klass.Get()) << " field=" << PrettyField(field) << " offset=" - << field->GetOffset(); + << field->GetOffsetDuringLinking(); if (i != 0) { ArtField* const prev_field = &fields[i - 1]; // NOTE: The field names can be the same. This is not possible in the Java language diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc index 9db47d842b..af2c2a2291 100644 --- a/runtime/native/java_lang_reflect_Constructor.cc +++ b/runtime/native/java_lang_reflect_Constructor.cc @@ -33,7 +33,7 @@ namespace art { * with an interface, array, or primitive class. If this is coming from * native, it is OK to avoid access checks since JNI does not enforce them. */ -static jobject Constructor_newInstance(JNIEnv* env, jobject javaMethod, jobjectArray javaArgs) { +static jobject Constructor_newInstance0(JNIEnv* env, jobject javaMethod, jobjectArray javaArgs) { ScopedFastNativeObjectAccess soa(env); mirror::Constructor* m = soa.Decode<mirror::Constructor*>(javaMethod); StackHandleScope<1> hs(soa.Self()); @@ -46,7 +46,8 @@ static jobject Constructor_newInstance(JNIEnv* env, jobject javaMethod, jobjectA } // Verify that we can access the class. if (!m->IsAccessible() && !c->IsPublic()) { - auto* caller = GetCallingClass(soa.Self(), 1); + // Go 2 frames back, this method is always called from the newInstance(Object... args) + auto* caller = GetCallingClass(soa.Self(), 2); // If caller is null, then we called from JNI, just avoid the check since JNI avoids most // access checks anyways. TODO: Investigate if this the correct behavior. if (caller != nullptr && !caller->CanAccess(c.Get())) { @@ -88,8 +89,16 @@ static jobject Constructor_newInstance(JNIEnv* env, jobject javaMethod, jobjectA return javaReceiver; } +static jobject Constructor_newInstanceFromSerialization(JNIEnv* env, jclass unused ATTRIBUTE_UNUSED, + jclass ctorClass, jclass allocClass) { + jmethodID ctor = env->GetMethodID(ctorClass, "<init>", "()V"); + DCHECK(ctor != NULL); + return env->NewObject(allocClass, ctor); +} + static JNINativeMethod gMethods[] = { - NATIVE_METHOD(Constructor, newInstance, "!([Ljava/lang/Object;)Ljava/lang/Object;"), + NATIVE_METHOD(Constructor, newInstance0, "!([Ljava/lang/Object;)Ljava/lang/Object;"), + NATIVE_METHOD(Constructor, newInstanceFromSerialization, "!(Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Object;"), }; void register_java_lang_reflect_Constructor(JNIEnv* env) { |