summaryrefslogtreecommitdiffstats
path: root/runtime/jni_internal.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/jni_internal.cc')
-rw-r--r--runtime/jni_internal.cc60
1 files changed, 26 insertions, 34 deletions
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index f435467e95..6ab44551d0 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -24,6 +24,7 @@
#include <vector>
#include "art_field-inl.h"
+#include "art_method-inl.h"
#include "atomic.h"
#include "base/allocator.h"
#include "base/logging.h"
@@ -38,7 +39,6 @@
#include "interpreter/interpreter.h"
#include "jni_env_ext.h"
#include "java_vm_ext.h"
-#include "mirror/art_method-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
#include "mirror/field-inl.h"
@@ -126,17 +126,18 @@ static jmethodID FindMethodID(ScopedObjectAccess& soa, jclass jni_class,
if (c == nullptr) {
return nullptr;
}
- mirror::ArtMethod* method = nullptr;
+ ArtMethod* method = nullptr;
+ auto pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
if (is_static) {
- method = c->FindDirectMethod(name, sig);
+ method = c->FindDirectMethod(name, sig, pointer_size);
} else if (c->IsInterface()) {
- method = c->FindInterfaceMethod(name, sig);
+ method = c->FindInterfaceMethod(name, sig, pointer_size);
} else {
- method = c->FindVirtualMethod(name, sig);
+ method = c->FindVirtualMethod(name, sig, pointer_size);
if (method == nullptr) {
// No virtual method matching the signature. Search declared
// private methods and constructors.
- method = c->FindDeclaredDirectMethod(name, sig);
+ method = c->FindDeclaredDirectMethod(name, sig, pointer_size);
}
}
if (method == nullptr || method->IsStatic() != is_static) {
@@ -148,7 +149,7 @@ static jmethodID FindMethodID(ScopedObjectAccess& soa, jclass jni_class,
static mirror::ClassLoader* GetClassLoader(const ScopedObjectAccess& soa)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- mirror::ArtMethod* method = soa.Self()->GetCurrentMethod(nullptr);
+ ArtMethod* method = soa.Self()->GetCurrentMethod(nullptr);
// If we are running Runtime.nativeLoad, use the overriding ClassLoader it set.
if (method == soa.DecodeMethod(WellKnownClasses::java_lang_Runtime_nativeLoad)) {
return soa.Decode<mirror::ClassLoader*>(soa.Self()->GetClassLoaderOverride());
@@ -312,26 +313,19 @@ static JavaVMExt* JavaVmExtFromEnv(JNIEnv* env) {
}
template <bool kNative>
-static mirror::ArtMethod* FindMethod(mirror::Class* c,
- const StringPiece& name,
- const StringPiece& sig)
+static ArtMethod* FindMethod(mirror::Class* c, const StringPiece& name, const StringPiece& sig)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- for (size_t i = 0; i < c->NumDirectMethods(); ++i) {
- mirror::ArtMethod* method = c->GetDirectMethod(i);
- if (kNative == method->IsNative() &&
- name == method->GetName() && method->GetSignature() == sig) {
- return method;
+ auto pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
+ for (auto& method : c->GetDirectMethods(pointer_size)) {
+ if (kNative == method.IsNative() && name == method.GetName() && method.GetSignature() == sig) {
+ return &method;
}
}
-
- for (size_t i = 0; i < c->NumVirtualMethods(); ++i) {
- mirror::ArtMethod* method = c->GetVirtualMethod(i);
- if (kNative == method->IsNative() &&
- name == method->GetName() && method->GetSignature() == sig) {
- return method;
+ for (auto& method : c->GetVirtualMethods(pointer_size)) {
+ if (kNative == method.IsNative() && name == method.GetName() && method.GetSignature() == sig) {
+ return &method;
}
}
-
return nullptr;
}
@@ -366,7 +360,7 @@ class JNI {
static jmethodID FromReflectedMethod(JNIEnv* env, jobject jlr_method) {
CHECK_NON_NULL_ARGUMENT(jlr_method);
ScopedObjectAccess soa(env);
- return soa.EncodeMethod(mirror::ArtMethod::FromReflectedMethod(soa, jlr_method));
+ return soa.EncodeMethod(ArtMethod::FromReflectedMethod(soa, jlr_method));
}
static jfieldID FromReflectedField(JNIEnv* env, jobject jlr_field) {
@@ -384,8 +378,7 @@ class JNI {
static jobject ToReflectedMethod(JNIEnv* env, jclass, jmethodID mid, jboolean) {
CHECK_NON_NULL_ARGUMENT(mid);
ScopedObjectAccess soa(env);
- mirror::ArtMethod* m = soa.DecodeMethod(mid);
- CHECK(!kMovingMethods);
+ ArtMethod* m = soa.DecodeMethod(mid);
mirror::AbstractMethod* method;
if (m->IsConstructor()) {
method = mirror::Constructor::CreateFromArtMethod(soa.Self(), m);
@@ -2151,7 +2144,7 @@ class JNI {
// Note: the right order is to try to find the method locally
// first, either as a direct or a virtual method. Then move to
// the parent.
- mirror::ArtMethod* m = nullptr;
+ ArtMethod* m = nullptr;
bool warn_on_going_to_parent = down_cast<JNIEnvExt*>(env)->vm->IsCheckJniEnabled();
for (mirror::Class* current_class = c;
current_class != nullptr;
@@ -2207,17 +2200,16 @@ class JNI {
VLOG(jni) << "[Unregistering JNI native methods for " << PrettyClass(c) << "]";
size_t unregistered_count = 0;
- for (size_t i = 0; i < c->NumDirectMethods(); ++i) {
- mirror::ArtMethod* m = c->GetDirectMethod(i);
- if (m->IsNative()) {
- m->UnregisterNative();
+ auto pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
+ for (auto& m : c->GetDirectMethods(pointer_size)) {
+ if (m.IsNative()) {
+ m.UnregisterNative();
unregistered_count++;
}
}
- for (size_t i = 0; i < c->NumVirtualMethods(); ++i) {
- mirror::ArtMethod* m = c->GetVirtualMethod(i);
- if (m->IsNative()) {
- m->UnregisterNative();
+ for (auto& m : c->GetVirtualMethods(pointer_size)) {
+ if (m.IsNative()) {
+ m.UnregisterNative();
unregistered_count++;
}
}