diff options
Diffstat (limited to 'runtime/class_linker.h')
-rw-r--r-- | runtime/class_linker.h | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/runtime/class_linker.h b/runtime/class_linker.h index d1c82776cc..4ca6024442 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -334,13 +334,6 @@ class ClassLinker { ObjPtr<mirror::ClassLoader> class_loader) REQUIRES_SHARED(Locks::mutator_lock_); - // Determine whether a dex cache result should be trusted, or an IncompatibleClassChangeError - // check and IllegalAccessError check should be performed even after a hit. - enum class ResolveMode { // private. - kNoChecks, - kCheckICCEAndIAE - }; - // Look up a previously resolved method with the given index. ArtMethod* LookupResolvedMethod(uint32_t method_idx, ObjPtr<mirror::DexCache> dex_cache, @@ -363,21 +356,16 @@ class ClassLinker { uint32_t method_idx) REQUIRES_SHARED(Locks::mutator_lock_); - // Resolve a method with a given ID from the DexFile associated with the given DexCache - // and ClassLoader, storing the result in DexCache. The ClassLinker and ClassLoader are - // used as in ResolveType. What is unique is the method type argument which is used to - // determine if this method is a direct, static, or virtual method. - template <ResolveMode kResolveMode> - ArtMethod* ResolveMethod(uint32_t method_idx, - Handle<mirror::DexCache> dex_cache, - Handle<mirror::ClassLoader> class_loader, - ArtMethod* referrer, - InvokeType type) - REQUIRES_SHARED(Locks::mutator_lock_) - REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); + // Check invoke type against the referenced class. Throws IncompatibleClassChangeError + // and returns true on mismatch (kInterface on a non-interface class, + // kVirtual on interface, kDefault on interface for dex files not supporting default methods), + // otherwise returns false. + static bool ThrowIfInvokeClassMismatch(ObjPtr<mirror::Class> cls, + const DexFile& dex_file, + InvokeType type) + REQUIRES_SHARED(Locks::mutator_lock_); - template <ResolveMode kResolveMode> - ArtMethod* ResolveMethod(Thread* self, uint32_t method_idx, ArtMethod* referrer, InvokeType type) + ArtMethod* ResolveMethodWithChecks(uint32_t method_idx, ArtMethod* referrer, InvokeType type) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); @@ -387,6 +375,10 @@ class ClassLinker { REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); + ArtMethod* ResolveMethodId(uint32_t method_idx, ArtMethod* referrer) + REQUIRES_SHARED(Locks::mutator_lock_) + REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); + ArtField* LookupResolvedField(uint32_t field_idx, ArtMethod* referrer, bool is_static) REQUIRES_SHARED(Locks::mutator_lock_); // Find a field by its field index. @@ -1408,23 +1400,6 @@ class ClassLinker { /*out*/bool* new_conflict, /*out*/ArtMethod** imt) REQUIRES_SHARED(Locks::mutator_lock_); - // Check invoke type against the referenced class. Throws IncompatibleClassChangeError - // (if `kThrowOnError`) and returns true on mismatch (kInterface on a non-interface class, - // kVirtual on interface, kDefault on interface for dex files not supporting default methods), - // otherwise returns false. - template <bool kThrowOnError, typename ClassGetter> - static bool CheckInvokeClassMismatch(ObjPtr<mirror::DexCache> dex_cache, - InvokeType type, - ClassGetter class_getter) - REQUIRES_SHARED(Locks::mutator_lock_); - // Helper that feeds the above function with `ClassGetter` doing `LookupResolvedType()`. - template <bool kThrow> - bool CheckInvokeClassMismatch(ObjPtr<mirror::DexCache> dex_cache, - InvokeType type, - uint32_t method_idx, - ObjPtr<mirror::ClassLoader> class_loader) - REQUIRES_SHARED(Locks::mutator_lock_); - ObjPtr<mirror::IfTable> GetArrayIfTable() REQUIRES_SHARED(Locks::mutator_lock_); bool OpenAndInitImageDexFiles(const gc::space::ImageSpace* space, |