diff options
author | 2016-09-08 13:43:31 +0100 | |
---|---|---|
committer | 2016-09-21 11:42:21 +0100 | |
commit | 0e8443995af602bcc2e70dcef1d20ee48acec934 (patch) | |
tree | 2d81b8db23bea139e40e33e4e9b8c69027fb1e56 | |
parent | c4cb3d532db8a500c1a15e8a0052895960259209 (diff) |
Collapse ART's AbstractMethod class into Executable
After the OpenJDK 8 pull there is now a common base class
for Method and Constructor that can be used instead.
Methods that are abstract on Executable but on Android
were implemented in AbstractMethod are now consistently
renamed to "{method}Internal", declared final and
given package-protected access.
For consistency with all other private, natively
implemented methods, the method getDeclaredAnnotations()
has been renamed getDeclaredAnnotationsNative().
Bug: 28666126
Bug: 31052885
Test: make test-art-host and cts run of CtsLibcoreTestCases
Change-Id: Ibfe6af6a47fe0cfffd0859ffbe58980aeb84e053
-rw-r--r-- | compiler/dex/dex_to_dex_compiler.cc | 2 | ||||
-rw-r--r-- | compiler/image_writer.cc | 6 | ||||
-rw-r--r-- | patchoat/patchoat.cc | 6 | ||||
-rw-r--r-- | runtime/Android.bp | 4 | ||||
-rw-r--r-- | runtime/art_method.cc | 8 | ||||
-rw-r--r-- | runtime/class_linker_test.cc | 20 | ||||
-rw-r--r-- | runtime/jni_internal.cc | 2 | ||||
-rw-r--r-- | runtime/mirror/abstract_method.h | 77 | ||||
-rw-r--r-- | runtime/mirror/executable.cc (renamed from runtime/mirror/abstract_method.cc) | 23 | ||||
-rw-r--r-- | runtime/mirror/executable.h | 33 | ||||
-rw-r--r-- | runtime/mirror/method.cc | 4 | ||||
-rw-r--r-- | runtime/mirror/method.h | 6 | ||||
-rw-r--r-- | runtime/native/java_lang_reflect_Executable.cc (renamed from runtime/native/java_lang_reflect_AbstractMethod.cc) | 26 | ||||
-rw-r--r-- | runtime/native/java_lang_reflect_Executable.h (renamed from runtime/native/java_lang_reflect_AbstractMethod.h) | 8 | ||||
-rw-r--r-- | runtime/reflection.cc | 8 | ||||
-rw-r--r-- | runtime/runtime.cc | 4 | ||||
-rw-r--r-- | runtime/verifier/method_verifier.cc | 2 | ||||
-rw-r--r-- | runtime/well_known_classes.cc | 8 | ||||
-rw-r--r-- | runtime/well_known_classes.h | 4 | ||||
-rw-r--r-- | test/031-class-attributes/src/ClassAttrs.java | 4 |
20 files changed, 101 insertions, 154 deletions
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc index 3ce786e008..c902d289e9 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -90,7 +90,7 @@ class DexCompiler { // Compiles a virtual method invocation into a quick virtual method invocation. // The method index is replaced by the vtable index where the corresponding - // AbstractMethod can be found. Therefore, this does not involve any resolution + // Executable can be found. Therefore, this does not involve any resolution // at runtime. // Since the method index is encoded with 16 bits, we can replace it only if the // vtable index can be encoded with 16 bits too. diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 3e6658ee40..cdb57a98ad 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -48,12 +48,12 @@ #include "intern_table.h" #include "linear_alloc.h" #include "lock_word.h" -#include "mirror/abstract_method.h" #include "mirror/array-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/dex_cache.h" #include "mirror/dex_cache-inl.h" +#include "mirror/executable.h" #include "mirror/method.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -1989,8 +1989,8 @@ void ImageWriter::FixupObject(Object* orig, Object* copy) { } else { if (klass == mirror::Method::StaticClass() || klass == mirror::Constructor::StaticClass()) { // Need to go update the ArtMethod. - auto* dest = down_cast<mirror::AbstractMethod*>(copy); - auto* src = down_cast<mirror::AbstractMethod*>(orig); + auto* dest = down_cast<mirror::Executable*>(copy); + auto* src = down_cast<mirror::Executable*>(orig); ArtMethod* src_method = src->GetArtMethod(); dest->SetArtMethod(GetImageMethodAddress(src_method)); } else if (!klass->IsArrayClass()) { diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index 5240011901..1af3660e8f 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -37,8 +37,8 @@ #include "elf_file_impl.h" #include "gc/space/image_space.h" #include "image-inl.h" -#include "mirror/abstract_method.h" #include "mirror/dex_cache.h" +#include "mirror/executable.h" #include "mirror/object-inl.h" #include "mirror/method.h" #include "mirror/reference.h" @@ -770,8 +770,8 @@ void PatchOat::VisitObject(mirror::Object* object) { } else if (object->GetClass() == mirror::Method::StaticClass() || object->GetClass() == mirror::Constructor::StaticClass()) { // Need to go update the ArtMethod. - auto* dest = down_cast<mirror::AbstractMethod*>(copy); - auto* src = down_cast<mirror::AbstractMethod*>(object); + auto* dest = down_cast<mirror::Executable*>(copy); + auto* src = down_cast<mirror::Executable*>(object); dest->SetArtMethod(RelocatedAddressOfPointer(src->GetArtMethod())); } } diff --git a/runtime/Android.bp b/runtime/Android.bp index 8c17653c79..6234a8459a 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -120,10 +120,10 @@ cc_defaults { "linear_alloc.cc", "mem_map.cc", "memory_region.cc", - "mirror/abstract_method.cc", "mirror/array.cc", "mirror/class.cc", "mirror/dex_cache.cc", + "mirror/executable.cc", "mirror/field.cc", "mirror/method.cc", "mirror/object.cc", @@ -151,9 +151,9 @@ cc_defaults { "native/java_lang_VMClassLoader.cc", "native/java_lang_ref_FinalizerReference.cc", "native/java_lang_ref_Reference.cc", - "native/java_lang_reflect_AbstractMethod.cc", "native/java_lang_reflect_Array.cc", "native/java_lang_reflect_Constructor.cc", + "native/java_lang_reflect_Executable.cc", "native/java_lang_reflect_Field.cc", "native/java_lang_reflect_Method.cc", "native/java_lang_reflect_Parameter.cc", diff --git a/runtime/art_method.cc b/runtime/art_method.cc index fd6c37a4e5..193bea167f 100644 --- a/runtime/art_method.cc +++ b/runtime/art_method.cc @@ -34,8 +34,8 @@ #include "jit/jit_code_cache.h" #include "jit/profiling_info.h" #include "jni_internal.h" -#include "mirror/abstract_method.h" #include "mirror/class-inl.h" +#include "mirror/executable.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" #include "mirror/string.h" @@ -52,9 +52,9 @@ extern "C" void art_quick_invoke_static_stub(ArtMethod*, uint32_t*, uint32_t, Th ArtMethod* ArtMethod::FromReflectedMethod(const ScopedObjectAccessAlreadyRunnable& soa, jobject jlr_method) { - auto* abstract_method = soa.Decode<mirror::AbstractMethod*>(jlr_method); - DCHECK(abstract_method != nullptr); - return abstract_method->GetArtMethod(); + auto* executable = soa.Decode<mirror::Executable*>(jlr_method); + DCHECK(executable != nullptr); + return executable->GetArtMethod(); } mirror::String* ArtMethod::GetNameAsString(Thread* self) { diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 5e0ee6fe23..65ce600027 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -28,7 +28,6 @@ #include "experimental_flags.h" #include "entrypoints/entrypoint_utils-inl.h" #include "gc/heap.h" -#include "mirror/abstract_method.h" #include "mirror/accessible_object.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" @@ -697,24 +696,18 @@ struct FieldOffsets : public CheckOffsets<mirror::Field> { struct ExecutableOffsets : public CheckOffsets<mirror::Executable> { ExecutableOffsets() : CheckOffsets<mirror::Executable>( false, "Ljava/lang/reflect/Executable;") { + addOffset(OFFSETOF_MEMBER(mirror::Executable, access_flags_), "accessFlags"); + addOffset(OFFSETOF_MEMBER(mirror::Executable, art_method_), "artMethod"); + addOffset(OFFSETOF_MEMBER(mirror::Executable, declaring_class_), "declaringClass"); + addOffset(OFFSETOF_MEMBER(mirror::Executable, declaring_class_of_overridden_method_), + "declaringClassOfOverriddenMethod"); + addOffset(OFFSETOF_MEMBER(mirror::Executable, dex_method_index_), "dexMethodIndex"); addOffset(OFFSETOF_MEMBER(mirror::Executable, has_real_parameter_data_), "hasRealParameterData"); addOffset(OFFSETOF_MEMBER(mirror::Executable, parameters_), "parameters"); }; }; -struct AbstractMethodOffsets : public CheckOffsets<mirror::AbstractMethod> { - AbstractMethodOffsets() : CheckOffsets<mirror::AbstractMethod>( - false, "Ljava/lang/reflect/AbstractMethod;") { - addOffset(OFFSETOF_MEMBER(mirror::AbstractMethod, access_flags_), "accessFlags"); - addOffset(OFFSETOF_MEMBER(mirror::AbstractMethod, art_method_), "artMethod"); - addOffset(OFFSETOF_MEMBER(mirror::AbstractMethod, declaring_class_), "declaringClass"); - addOffset(OFFSETOF_MEMBER(mirror::AbstractMethod, declaring_class_of_overridden_method_), - "declaringClassOfOverriddenMethod"); - addOffset(OFFSETOF_MEMBER(mirror::AbstractMethod, dex_method_index_), "dexMethodIndex"); - }; -}; - // C++ fields must exactly match the fields in the Java classes. If this fails, // reorder the fields in the C++ class. Managed class fields are ordered by // ClassLinker::LinkFields. @@ -733,7 +726,6 @@ TEST_F(ClassLinkerTest, ValidateFieldOrderOfJavaCppUnionClasses) { EXPECT_TRUE(AccessibleObjectOffsets().Check()); EXPECT_TRUE(FieldOffsets().Check()); EXPECT_TRUE(ExecutableOffsets().Check()); - EXPECT_TRUE(AbstractMethodOffsets().Check()); } TEST_F(ClassLinkerTest, FindClassNonexistent) { diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index a434442d93..d9cb1c66a4 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -375,7 +375,7 @@ class JNI { CHECK_NON_NULL_ARGUMENT(mid); ScopedObjectAccess soa(env); ArtMethod* m = soa.DecodeMethod(mid); - mirror::AbstractMethod* method; + mirror::Executable* method; DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize); DCHECK(!Runtime::Current()->IsActiveTransaction()); if (m->IsConstructor()) { diff --git a/runtime/mirror/abstract_method.h b/runtime/mirror/abstract_method.h deleted file mode 100644 index 9c2061387e..0000000000 --- a/runtime/mirror/abstract_method.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ -#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ - -#include "executable.h" -#include "gc_root.h" -#include "object.h" -#include "object_callbacks.h" -#include "read_barrier_option.h" - -namespace art { - -struct AbstractMethodOffsets; -class ArtMethod; - -namespace mirror { - -// C++ mirror of java.lang.reflect.AbstractMethod. -class MANAGED AbstractMethod : public Executable { - public: - // Called from Constructor::CreateFromArtMethod, Method::CreateFromArtMethod. - template <PointerSize kPointerSize, bool kTransactionActive> - bool CreateFromArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) - REQUIRES(!Roles::uninterruptible_); - - ArtMethod* GetArtMethod() REQUIRES_SHARED(Locks::mutator_lock_); - // Only used by the image writer. - template <bool kTransactionActive = false> - void SetArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_); - mirror::Class* GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_); - - private: - static MemberOffset ArtMethodOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, art_method_)); - } - static MemberOffset DeclaringClassOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_)); - } - static MemberOffset DeclaringClassOfOverriddenMethodOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_of_overridden_method_)); - } - static MemberOffset AccessFlagsOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, access_flags_)); - } - static MemberOffset DexMethodIndexOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, dex_method_index_)); - } - - HeapReference<mirror::Class> declaring_class_; - HeapReference<mirror::Class> declaring_class_of_overridden_method_; - uint64_t art_method_; - uint32_t access_flags_; - uint32_t dex_method_index_; - - friend struct art::AbstractMethodOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(AbstractMethod); -}; - -} // namespace mirror -} // namespace art - -#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ diff --git a/runtime/mirror/abstract_method.cc b/runtime/mirror/executable.cc index b4dce583e1..33ebd817d1 100644 --- a/runtime/mirror/abstract_method.cc +++ b/runtime/mirror/executable.cc @@ -14,15 +14,14 @@ * limitations under the License. */ -#include "abstract_method.h" - #include "art_method-inl.h" +#include "executable.h" namespace art { namespace mirror { template <PointerSize kPointerSize, bool kTransactionActive> -bool AbstractMethod::CreateFromArtMethod(ArtMethod* method) { +bool Executable::CreateFromArtMethod(ArtMethod* method) { auto* interface_method = method->GetInterfaceMethodIfProxy(kPointerSize); SetArtMethod<kTransactionActive>(method); SetFieldObject<kTransactionActive>(DeclaringClassOffset(), method->GetDeclaringClass()); @@ -33,28 +32,28 @@ bool AbstractMethod::CreateFromArtMethod(ArtMethod* method) { return true; } -template bool AbstractMethod::CreateFromArtMethod<PointerSize::k32, false>( +template bool Executable::CreateFromArtMethod<PointerSize::k32, false>( ArtMethod* method); -template bool AbstractMethod::CreateFromArtMethod<PointerSize::k32, true>( +template bool Executable::CreateFromArtMethod<PointerSize::k32, true>( ArtMethod* method); -template bool AbstractMethod::CreateFromArtMethod<PointerSize::k64, false>( +template bool Executable::CreateFromArtMethod<PointerSize::k64, false>( ArtMethod* method); -template bool AbstractMethod::CreateFromArtMethod<PointerSize::k64, true>( +template bool Executable::CreateFromArtMethod<PointerSize::k64, true>( ArtMethod* method); -ArtMethod* AbstractMethod::GetArtMethod() { +ArtMethod* Executable::GetArtMethod() { return reinterpret_cast<ArtMethod*>(GetField64(ArtMethodOffset())); } template <bool kTransactionActive> -void AbstractMethod::SetArtMethod(ArtMethod* method) { +void Executable::SetArtMethod(ArtMethod* method) { SetField64<kTransactionActive>(ArtMethodOffset(), reinterpret_cast<uint64_t>(method)); } -template void AbstractMethod::SetArtMethod<false>(ArtMethod* method); -template void AbstractMethod::SetArtMethod<true>(ArtMethod* method); +template void Executable::SetArtMethod<false>(ArtMethod* method); +template void Executable::SetArtMethod<true>(ArtMethod* method); -mirror::Class* AbstractMethod::GetDeclaringClass() { +mirror::Class* Executable::GetDeclaringClass() { return GetFieldObject<mirror::Class>(DeclaringClassOffset()); } diff --git a/runtime/mirror/executable.h b/runtime/mirror/executable.h index 232fce8693..6c465f6bbb 100644 --- a/runtime/mirror/executable.h +++ b/runtime/mirror/executable.h @@ -32,9 +32,42 @@ namespace mirror { // C++ mirror of java.lang.reflect.Executable. class MANAGED Executable : public AccessibleObject { + public: + // Called from Constructor::CreateFromArtMethod, Method::CreateFromArtMethod. + template <PointerSize kPointerSize, bool kTransactionActive> + bool CreateFromArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) + REQUIRES(!Roles::uninterruptible_); + + ArtMethod* GetArtMethod() REQUIRES_SHARED(Locks::mutator_lock_); + // Only used by the image writer. + template <bool kTransactionActive = false> + void SetArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_); + mirror::Class* GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_); + private: uint16_t has_real_parameter_data_; + HeapReference<mirror::Class> declaring_class_; + HeapReference<mirror::Class> declaring_class_of_overridden_method_; HeapReference<mirror::Array> parameters_; + uint64_t art_method_; + uint32_t access_flags_; + uint32_t dex_method_index_; + + static MemberOffset ArtMethodOffset() { + return MemberOffset(OFFSETOF_MEMBER(Executable, art_method_)); + } + static MemberOffset DeclaringClassOffset() { + return MemberOffset(OFFSETOF_MEMBER(Executable, declaring_class_)); + } + static MemberOffset DeclaringClassOfOverriddenMethodOffset() { + return MemberOffset(OFFSETOF_MEMBER(Executable, declaring_class_of_overridden_method_)); + } + static MemberOffset AccessFlagsOffset() { + return MemberOffset(OFFSETOF_MEMBER(Executable, access_flags_)); + } + static MemberOffset DexMethodIndexOffset() { + return MemberOffset(OFFSETOF_MEMBER(Executable, dex_method_index_)); + } friend struct art::ExecutableOffsets; // for verifying offset information DISALLOW_IMPLICIT_CONSTRUCTORS(Executable); diff --git a/runtime/mirror/method.cc b/runtime/mirror/method.cc index ef16719f27..71bac7e3d6 100644 --- a/runtime/mirror/method.cc +++ b/runtime/mirror/method.cc @@ -56,7 +56,7 @@ Method* Method::CreateFromArtMethod(Thread* self, ArtMethod* method) { DCHECK(!method->IsConstructor()) << PrettyMethod(method); auto* ret = down_cast<Method*>(StaticClass()->AllocObject(self)); if (LIKELY(ret != nullptr)) { - static_cast<AbstractMethod*>(ret)-> + static_cast<Executable*>(ret)-> CreateFromArtMethod<kPointerSize, kTransactionActive>(method); } return ret; @@ -108,7 +108,7 @@ Constructor* Constructor::CreateFromArtMethod(Thread* self, ArtMethod* method) { DCHECK(method->IsConstructor()) << PrettyMethod(method); auto* ret = down_cast<Constructor*>(StaticClass()->AllocObject(self)); if (LIKELY(ret != nullptr)) { - static_cast<AbstractMethod*>(ret)-> + static_cast<Executable*>(ret)-> CreateFromArtMethod<kPointerSize, kTransactionActive>(method); } return ret; diff --git a/runtime/mirror/method.h b/runtime/mirror/method.h index 6881991736..205ea7a050 100644 --- a/runtime/mirror/method.h +++ b/runtime/mirror/method.h @@ -17,8 +17,8 @@ #ifndef ART_RUNTIME_MIRROR_METHOD_H_ #define ART_RUNTIME_MIRROR_METHOD_H_ -#include "abstract_method.h" #include "gc_root.h" +#include "executable.h" namespace art { namespace mirror { @@ -26,7 +26,7 @@ namespace mirror { class Class; // C++ mirror of java.lang.reflect.Method. -class MANAGED Method : public AbstractMethod { +class MANAGED Method : public Executable { public: template <PointerSize kPointerSize, bool kTransactionActive> static Method* CreateFromArtMethod(Thread* self, ArtMethod* method) @@ -58,7 +58,7 @@ class MANAGED Method : public AbstractMethod { }; // C++ mirror of java.lang.reflect.Constructor. -class MANAGED Constructor: public AbstractMethod { +class MANAGED Constructor: public Executable { public: template <PointerSize kPointerSize, bool kTransactionActive> static Constructor* CreateFromArtMethod(Thread* self, ArtMethod* method) diff --git a/runtime/native/java_lang_reflect_AbstractMethod.cc b/runtime/native/java_lang_reflect_Executable.cc index 254f8dbb4c..8fcf6aca08 100644 --- a/runtime/native/java_lang_reflect_AbstractMethod.cc +++ b/runtime/native/java_lang_reflect_Executable.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "java_lang_reflect_AbstractMethod.h" +#include "java_lang_reflect_Executable.h" #include "art_method-inl.h" #include "dex_file_annotations.h" @@ -28,7 +28,7 @@ namespace art { -static jobjectArray AbstractMethod_getDeclaredAnnotations(JNIEnv* env, jobject javaMethod) { +static jobjectArray Executable_getDeclaredAnnotationsNative(JNIEnv* env, jobject javaMethod) { ScopedFastNativeObjectAccess soa(env); ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod); if (method->GetDeclaringClass()->IsProxyClass()) { @@ -42,7 +42,7 @@ static jobjectArray AbstractMethod_getDeclaredAnnotations(JNIEnv* env, jobject j return soa.AddLocalReference<jobjectArray>(annotations::GetAnnotationsForMethod(method)); } -static jobject AbstractMethod_getAnnotationNative(JNIEnv* env, +static jobject Executable_getAnnotationNative(JNIEnv* env, jobject javaMethod, jclass annotationType) { ScopedFastNativeObjectAccess soa(env); @@ -56,7 +56,7 @@ static jobject AbstractMethod_getAnnotationNative(JNIEnv* env, } } -static jobjectArray AbstractMethod_getSignatureAnnotation(JNIEnv* env, jobject javaMethod) { +static jobjectArray Executable_getSignatureAnnotation(JNIEnv* env, jobject javaMethod) { ScopedFastNativeObjectAccess soa(env); ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod); if (method->GetDeclaringClass()->IsProxyClass()) { @@ -67,7 +67,7 @@ static jobjectArray AbstractMethod_getSignatureAnnotation(JNIEnv* env, jobject j } -static jobjectArray AbstractMethod_getParameterAnnotationsNative(JNIEnv* env, jobject javaMethod) { +static jobjectArray Executable_getParameterAnnotationsNative(JNIEnv* env, jobject javaMethod) { ScopedFastNativeObjectAccess soa(env); ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod); if (method->IsProxyMethod()) { @@ -77,7 +77,7 @@ static jobjectArray AbstractMethod_getParameterAnnotationsNative(JNIEnv* env, jo } } -static jboolean AbstractMethod_isAnnotationPresentNative(JNIEnv* env, +static jboolean Executable_isAnnotationPresentNative(JNIEnv* env, jobject javaMethod, jclass annotationType) { ScopedFastNativeObjectAccess soa(env); @@ -91,17 +91,17 @@ static jboolean AbstractMethod_isAnnotationPresentNative(JNIEnv* env, } static JNINativeMethod gMethods[] = { - NATIVE_METHOD(AbstractMethod, getAnnotationNative, + NATIVE_METHOD(Executable, getAnnotationNative, "!(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;"), - NATIVE_METHOD(AbstractMethod, getDeclaredAnnotations, "!()[Ljava/lang/annotation/Annotation;"), - NATIVE_METHOD(AbstractMethod, getParameterAnnotationsNative, + NATIVE_METHOD(Executable, getDeclaredAnnotationsNative, "!()[Ljava/lang/annotation/Annotation;"), + NATIVE_METHOD(Executable, getParameterAnnotationsNative, "!()[[Ljava/lang/annotation/Annotation;"), - NATIVE_METHOD(AbstractMethod, getSignatureAnnotation, "!()[Ljava/lang/String;"), - NATIVE_METHOD(AbstractMethod, isAnnotationPresentNative, "!(Ljava/lang/Class;)Z"), + NATIVE_METHOD(Executable, getSignatureAnnotation, "!()[Ljava/lang/String;"), + NATIVE_METHOD(Executable, isAnnotationPresentNative, "!(Ljava/lang/Class;)Z"), }; -void register_java_lang_reflect_AbstractMethod(JNIEnv* env) { - REGISTER_NATIVE_METHODS("java/lang/reflect/AbstractMethod"); +void register_java_lang_reflect_Executable(JNIEnv* env) { + REGISTER_NATIVE_METHODS("java/lang/reflect/Executable"); } } // namespace art diff --git a/runtime/native/java_lang_reflect_AbstractMethod.h b/runtime/native/java_lang_reflect_Executable.h index 222e5a05d0..0cfed62e49 100644 --- a/runtime/native/java_lang_reflect_AbstractMethod.h +++ b/runtime/native/java_lang_reflect_Executable.h @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_ABSTRACTMETHOD_H_ -#define ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_ABSTRACTMETHOD_H_ +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_EXECUTABLE_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_EXECUTABLE_H_ #include <jni.h> namespace art { -void register_java_lang_reflect_AbstractMethod(JNIEnv* env); +void register_java_lang_reflect_Executable(JNIEnv* env); } // namespace art -#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_ABSTRACTMETHOD_H_ +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_EXECUTABLE_H_ diff --git a/runtime/reflection.cc b/runtime/reflection.cc index 67e3fe8864..c69e98c8ee 100644 --- a/runtime/reflection.cc +++ b/runtime/reflection.cc @@ -24,8 +24,8 @@ #include "dex_file-inl.h" #include "indirect_reference_table-inl.h" #include "jni_internal.h" -#include "mirror/abstract_method.h" #include "mirror/class-inl.h" +#include "mirror/executable.h" #include "mirror/object_array-inl.h" #include "nth_caller_visitor.h" #include "scoped_thread_state_change.h" @@ -578,9 +578,9 @@ jobject InvokeMethod(const ScopedObjectAccessAlreadyRunnable& soa, jobject javaM return nullptr; } - auto* abstract_method = soa.Decode<mirror::AbstractMethod*>(javaMethod); - const bool accessible = abstract_method->IsAccessible(); - ArtMethod* m = abstract_method->GetArtMethod(); + auto* executable = soa.Decode<mirror::Executable*>(javaMethod); + const bool accessible = executable->IsAccessible(); + ArtMethod* m = executable->GetArtMethod(); mirror::Class* declaring_class = m->GetDeclaringClass(); if (UNLIKELY(!declaring_class->IsInitialized())) { diff --git a/runtime/runtime.cc b/runtime/runtime.cc index f144b981d3..15e3b1cfc7 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -108,9 +108,9 @@ #include "native/java_lang_VMClassLoader.h" #include "native/java_lang_ref_FinalizerReference.h" #include "native/java_lang_ref_Reference.h" -#include "native/java_lang_reflect_AbstractMethod.h" #include "native/java_lang_reflect_Array.h" #include "native/java_lang_reflect_Constructor.h" +#include "native/java_lang_reflect_Executable.h" #include "native/java_lang_reflect_Field.h" #include "native/java_lang_reflect_Method.h" #include "native/java_lang_reflect_Parameter.h" @@ -1378,9 +1378,9 @@ void Runtime::RegisterRuntimeNativeMethods(JNIEnv* env) { register_java_lang_DexCache(env); register_java_lang_Object(env); register_java_lang_ref_FinalizerReference(env); - register_java_lang_reflect_AbstractMethod(env); register_java_lang_reflect_Array(env); register_java_lang_reflect_Constructor(env); + register_java_lang_reflect_Executable(env); register_java_lang_reflect_Field(env); register_java_lang_reflect_Method(env); register_java_lang_reflect_Parameter(env); diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index f1d3189309..abd741cac4 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -3284,7 +3284,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { } break; // Note: the following instructions encode offsets derived from class linking. - // As such they use Class*/Field*/AbstractMethod* as these offsets only have + // As such they use Class*/Field*/Executable* as these offsets only have // meaning if the class linking and resolution were successful. case Instruction::IGET_QUICK: VerifyQuickFieldAccess<FieldAccessType::kAccGet>(inst, reg_types_.Integer(), true); diff --git a/runtime/well_known_classes.cc b/runtime/well_known_classes.cc index 5f5fbc89f9..16c7f773c8 100644 --- a/runtime/well_known_classes.cc +++ b/runtime/well_known_classes.cc @@ -48,8 +48,8 @@ jclass WellKnownClasses::java_lang_IllegalAccessError; jclass WellKnownClasses::java_lang_NoClassDefFoundError; jclass WellKnownClasses::java_lang_Object; jclass WellKnownClasses::java_lang_OutOfMemoryError; -jclass WellKnownClasses::java_lang_reflect_AbstractMethod; jclass WellKnownClasses::java_lang_reflect_Constructor; +jclass WellKnownClasses::java_lang_reflect_Executable; jclass WellKnownClasses::java_lang_reflect_Field; jclass WellKnownClasses::java_lang_reflect_Method; jclass WellKnownClasses::java_lang_reflect_Proxy; @@ -154,7 +154,7 @@ jfieldID WellKnownClasses::java_lang_Throwable_detailMessage; jfieldID WellKnownClasses::java_lang_Throwable_stackTrace; jfieldID WellKnownClasses::java_lang_Throwable_stackState; jfieldID WellKnownClasses::java_lang_Throwable_suppressedExceptions; -jfieldID WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod; +jfieldID WellKnownClasses::java_lang_reflect_Executable_artMethod; jfieldID WellKnownClasses::java_lang_reflect_Proxy_h; jfieldID WellKnownClasses::java_nio_DirectByteBuffer_capacity; jfieldID WellKnownClasses::java_nio_DirectByteBuffer_effectiveDirectAddress; @@ -237,8 +237,8 @@ void WellKnownClasses::Init(JNIEnv* env) { java_lang_ExceptionInInitializerError = CacheClass(env, "java/lang/ExceptionInInitializerError"); java_lang_IllegalAccessError = CacheClass(env, "java/lang/IllegalAccessError"); java_lang_NoClassDefFoundError = CacheClass(env, "java/lang/NoClassDefFoundError"); - java_lang_reflect_AbstractMethod = CacheClass(env, "java/lang/reflect/AbstractMethod"); java_lang_reflect_Constructor = CacheClass(env, "java/lang/reflect/Constructor"); + java_lang_reflect_Executable = CacheClass(env, "java/lang/reflect/Executable"); java_lang_reflect_Field = CacheClass(env, "java/lang/reflect/Field"); java_lang_reflect_Method = CacheClass(env, "java/lang/reflect/Method"); java_lang_reflect_Proxy = CacheClass(env, "java/lang/reflect/Proxy"); @@ -362,7 +362,7 @@ void WellKnownClasses::Init(JNIEnv* env) { java_lang_Throwable_stackTrace = CacheField(env, java_lang_Throwable, false, "stackTrace", "[Ljava/lang/StackTraceElement;"); 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_AbstractMethod_artMethod = CacheField(env, java_lang_reflect_AbstractMethod, false, "artMethod", "J"); + 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"); diff --git a/runtime/well_known_classes.h b/runtime/well_known_classes.h index ce710ffa29..b4d179c4df 100644 --- a/runtime/well_known_classes.h +++ b/runtime/well_known_classes.h @@ -59,8 +59,8 @@ struct WellKnownClasses { static jclass java_lang_NoClassDefFoundError; static jclass java_lang_Object; static jclass java_lang_OutOfMemoryError; - static jclass java_lang_reflect_AbstractMethod; static jclass java_lang_reflect_Constructor; + static jclass java_lang_reflect_Executable; static jclass java_lang_reflect_Field; static jclass java_lang_reflect_Method; static jclass java_lang_reflect_Proxy; @@ -148,7 +148,7 @@ struct WellKnownClasses { static jfieldID dalvik_system_DexPathList_dexElements; static jfieldID dalvik_system_DexPathList__Element_dexFile; static jfieldID dalvik_system_PathClassLoader_pathList; - static jfieldID java_lang_reflect_AbstractMethod_artMethod; + static jfieldID java_lang_reflect_Executable_artMethod; static jfieldID java_lang_reflect_Proxy_h; static jfieldID java_lang_Thread_daemon; static jfieldID java_lang_Thread_group; diff --git a/test/031-class-attributes/src/ClassAttrs.java b/test/031-class-attributes/src/ClassAttrs.java index 346e13d110..39e69a3066 100644 --- a/test/031-class-attributes/src/ClassAttrs.java +++ b/test/031-class-attributes/src/ClassAttrs.java @@ -1,9 +1,9 @@ import otherpackage.OtherPackageClass; import java.io.Serializable; -import java.lang.reflect.AbstractMethod; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Constructor; +import java.lang.reflect.Executable; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -223,7 +223,7 @@ public class ClassAttrs { try { Class<?> c = obj.getClass(); if (c == Method.class || c == Constructor.class) { - c = AbstractMethod.class; + c = Executable.class; } method = c.getDeclaredMethod("getSignatureAttribute"); method.setAccessible(true); |