blob: 6ec10511dd5418eee7c26489f8483b2e085329ec [file] [log] [blame]
Elliott Hughesd369bb72011-09-12 14:41:14 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "jni_internal.h"
18#include "class_linker.h"
Brian Carlstromf91c8c32011-09-21 17:30:34 -070019#include "class_loader.h"
Elliott Hughesd369bb72011-09-12 14:41:14 -070020#include "object.h"
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080021#include "object_utils.h"
Elliott Hughes80609252011-09-23 17:24:51 -070022#include "ScopedLocalRef.h"
Brian Carlstromf91c8c32011-09-21 17:30:34 -070023#include "ScopedUtfChars.h"
Elliott Hughesd369bb72011-09-12 14:41:14 -070024
25#include "JniConstants.h" // Last to avoid problems with LOG redefinition.
26
27namespace art {
28
29namespace {
30
Brian Carlstromf91c8c32011-09-21 17:30:34 -070031// "name" is in "binary name" format, e.g. "dalvik.system.Debug$1".
32jclass Class_classForName(JNIEnv* env, jclass, jstring javaName, jboolean initialize, jobject javaLoader) {
Brian Carlstromb82b6872011-10-26 17:18:07 -070033 ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable);
Brian Carlstromf91c8c32011-09-21 17:30:34 -070034 ScopedUtfChars name(env, javaName);
35 if (name.c_str() == NULL) {
36 return NULL;
37 }
38
39 // We need to validate and convert the name (from x.y.z to x/y/z). This
40 // is especially handy for array types, since we want to avoid
41 // auto-generating bogus array classes.
Elliott Hughes906e6852011-10-28 14:52:10 -070042 if (!IsValidBinaryClassName(name.c_str())) {
Elliott Hughes5cb5ad22011-10-02 12:13:39 -070043 Thread::Current()->ThrowNewExceptionF("Ljava/lang/ClassNotFoundException;",
Brian Carlstromf91c8c32011-09-21 17:30:34 -070044 "Invalid name: %s", name.c_str());
45 return NULL;
46 }
47
48 std::string descriptor(DotToDescriptor(name.c_str()));
49 Object* loader = Decode<Object*>(env, javaLoader);
50 ClassLoader* class_loader = down_cast<ClassLoader*>(loader);
51 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
52 Class* c = class_linker->FindClass(descriptor.c_str(), class_loader);
Brian Carlstrom395520e2011-09-25 19:35:00 -070053 if (c == NULL) {
Elliott Hughes844f9a02012-01-24 20:19:58 -080054 ScopedLocalRef<jthrowable> cause(env, env->ExceptionOccurred());
Brian Carlstrom395520e2011-09-25 19:35:00 -070055 env->ExceptionClear();
Elliott Hughes844f9a02012-01-24 20:19:58 -080056 static jclass ClassNotFoundException_class = CacheClass(env, "java/lang/ClassNotFoundException");
57 static jmethodID ctor = env->GetMethodID(ClassNotFoundException_class, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V");
58 jthrowable cnfe = reinterpret_cast<jthrowable>(env->NewObject(ClassNotFoundException_class, ctor, javaName, cause.get()));
59 env->Throw(cnfe);
Brian Carlstrom395520e2011-09-25 19:35:00 -070060 return NULL;
61 }
Brian Carlstromf91c8c32011-09-21 17:30:34 -070062 if (initialize) {
63 class_linker->EnsureInitialized(c, true);
64 }
65 return AddLocalReference<jclass>(env, c);
66}
67
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080068jint Class_getAnnotationDirectoryOffset(JNIEnv* env, jclass javaClass) {
69 Class* c = Decode<Class*>(env, javaClass);
70 if (c->IsPrimitive() || c->IsArrayClass() || c->IsProxyClass()) {
71 return 0; // primitive, array and proxy classes don't have class definitions
72 }
73 const DexFile::ClassDef* class_def = ClassHelper(c).GetClassDef();
74 if (class_def == NULL) {
75 return 0; // not found
76 } else {
77 return class_def->annotations_off_;
78 }
79}
80
Elliott Hughes80609252011-09-23 17:24:51 -070081template<typename T>
82jobjectArray ToArray(JNIEnv* env, const char* array_class_name, const std::vector<T*>& objects) {
83 jclass array_class = env->FindClass(array_class_name);
84 jobjectArray result = env->NewObjectArray(objects.size(), array_class, NULL);
85 for (size_t i = 0; i < objects.size(); ++i) {
86 ScopedLocalRef<jobject> object(env, AddLocalReference<jobject>(env, objects[i]));
87 env->SetObjectArrayElement(result, i, object.get());
88 }
89 return result;
90}
91
Ian Rogersd418eda2012-01-30 12:14:28 -080092static bool IsVisibleConstructor(Method* m, bool public_only) {
Elliott Hughes80609252011-09-23 17:24:51 -070093 if (public_only && !m->IsPublic()) {
94 return false;
95 }
Ian Rogers9074b992011-10-26 17:41:55 -070096 if (m->IsStatic()) {
Elliott Hughes80609252011-09-23 17:24:51 -070097 return false;
98 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080099 return m->IsConstructor();
Elliott Hughes80609252011-09-23 17:24:51 -0700100}
101
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800102jobjectArray Class_getDeclaredConstructors(JNIEnv* env, jclass javaClass, jboolean publicOnly) {
Elliott Hughes80609252011-09-23 17:24:51 -0700103 Class* c = Decode<Class*>(env, javaClass);
104
105 std::vector<Method*> constructors;
106 for (size_t i = 0; i < c->NumDirectMethods(); ++i) {
107 Method* m = c->GetDirectMethod(i);
108 if (IsVisibleConstructor(m, publicOnly)) {
109 constructors.push_back(m);
110 }
111 }
112
113 return ToArray(env, "java/lang/reflect/Constructor", constructors);
114}
115
Ian Rogersd418eda2012-01-30 12:14:28 -0800116static bool IsVisibleField(Field* f, bool public_only) {
Elliott Hughesc0dd3122011-09-26 10:15:43 -0700117 if (public_only && !f->IsPublic()) {
Elliott Hughes80609252011-09-23 17:24:51 -0700118 return false;
119 }
Elliott Hughes80609252011-09-23 17:24:51 -0700120 return true;
121}
122
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800123jobjectArray Class_getDeclaredFields(JNIEnv* env, jclass javaClass, jboolean publicOnly) {
Elliott Hughes80609252011-09-23 17:24:51 -0700124 Class* c = Decode<Class*>(env, javaClass);
125
126 std::vector<Field*> fields;
127 for (size_t i = 0; i < c->NumInstanceFields(); ++i) {
128 Field* f = c->GetInstanceField(i);
129 if (IsVisibleField(f, publicOnly)) {
130 fields.push_back(f);
131 }
Jesse Wilson53494312011-11-29 16:43:09 -0500132 if (env->ExceptionOccurred()) {
133 return NULL;
134 }
Elliott Hughes80609252011-09-23 17:24:51 -0700135 }
136 for (size_t i = 0; i < c->NumStaticFields(); ++i) {
137 Field* f = c->GetStaticField(i);
138 if (IsVisibleField(f, publicOnly)) {
139 fields.push_back(f);
140 }
Jesse Wilson53494312011-11-29 16:43:09 -0500141 if (env->ExceptionOccurred()) {
142 return NULL;
143 }
Elliott Hughes80609252011-09-23 17:24:51 -0700144 }
145
146 return ToArray(env, "java/lang/reflect/Field", fields);
147}
148
Ian Rogersd418eda2012-01-30 12:14:28 -0800149static bool IsVisibleMethod(Method* m, bool public_only) {
Elliott Hughes80609252011-09-23 17:24:51 -0700150 if (public_only && !m->IsPublic()) {
151 return false;
152 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800153 if (m->IsConstructor()) {
Elliott Hughes80609252011-09-23 17:24:51 -0700154 return false;
155 }
Elliott Hughes80609252011-09-23 17:24:51 -0700156 return true;
157}
158
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800159jobjectArray Class_getDeclaredMethods(JNIEnv* env, jclass javaClass, jboolean publicOnly) {
Elliott Hughes80609252011-09-23 17:24:51 -0700160 Class* c = Decode<Class*>(env, javaClass);
Elliott Hughes80609252011-09-23 17:24:51 -0700161 std::vector<Method*> methods;
162 for (size_t i = 0; i < c->NumVirtualMethods(); ++i) {
163 Method* m = c->GetVirtualMethod(i);
164 if (IsVisibleMethod(m, publicOnly)) {
165 methods.push_back(m);
166 }
Jesse Wilson53494312011-11-29 16:43:09 -0500167 if (env->ExceptionOccurred()) {
168 return NULL;
169 }
Elliott Hughes80609252011-09-23 17:24:51 -0700170 }
171 for (size_t i = 0; i < c->NumDirectMethods(); ++i) {
172 Method* m = c->GetDirectMethod(i);
173 if (IsVisibleMethod(m, publicOnly)) {
174 methods.push_back(m);
175 }
Jesse Wilson53494312011-11-29 16:43:09 -0500176 if (env->ExceptionOccurred()) {
177 return NULL;
178 }
Elliott Hughes80609252011-09-23 17:24:51 -0700179 }
180
181 return ToArray(env, "java/lang/reflect/Method", methods);
182}
183
Jesse Wilson6bf19152011-09-29 13:12:33 -0400184jobject Class_getDex(JNIEnv* env, jobject javaClass) {
185 Class* c = Decode<Class*>(env, javaClass);
186
187 DexCache* dex_cache = c->GetDexCache();
188 if (dex_cache == NULL) {
189 return NULL;
190 }
191
192 return Runtime::Current()->GetClassLinker()->FindDexFile(dex_cache).GetDexObject(env);
193}
194
Ian Rogersd418eda2012-01-30 12:14:28 -0800195static bool MethodMatches(MethodHelper* mh, const std::string& name, ObjectArray<Class>* arg_array) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800196 if (name != mh->GetName()) {
Elliott Hughes418d20f2011-09-22 14:00:39 -0700197 return false;
198 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800199 const DexFile::TypeList* m_type_list = mh->GetParameterTypeList();
200 uint32_t m_type_list_size = m_type_list == NULL ? 0 : m_type_list->Size();
201 uint32_t sig_length = arg_array->GetLength();
202
203 if (m_type_list_size != sig_length) {
Elliott Hughes418d20f2011-09-22 14:00:39 -0700204 return false;
205 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800206
207 for (uint32_t i = 0; i < sig_length; i++) {
208 if (mh->GetClassFromTypeIdx(m_type_list->GetTypeItem(i).type_idx_) != arg_array->Get(i)) {
209 return false;
210 }
Jesse Wilson8ea36f82011-11-21 10:35:06 -0500211 }
Elliott Hughes418d20f2011-09-22 14:00:39 -0700212 return true;
213}
214
Ian Rogersd418eda2012-01-30 12:14:28 -0800215static Method* FindConstructorOrMethodInArray(ObjectArray<Method>* methods, const std::string& name,
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800216 ObjectArray<Class>* arg_array) {
Jesse Wilson8ea36f82011-11-21 10:35:06 -0500217 if (methods == NULL) {
218 return NULL;
219 }
220 Method* result = NULL;
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800221 MethodHelper mh;
Jesse Wilson8ea36f82011-11-21 10:35:06 -0500222 for (int32_t i = 0; i < methods->GetLength(); ++i) {
223 Method* method = methods->Get(i);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800224 mh.ChangeMethod(method);
225 if (method->IsMiranda() || !MethodMatches(&mh, name, arg_array)) {
Jesse Wilson8ea36f82011-11-21 10:35:06 -0500226 continue;
227 }
228
229 result = method;
230
231 // Covariant return types permit the class to define multiple
232 // methods with the same name and parameter types. Prefer to return
233 // a non-synthetic method in such situations. We may still return
234 // a synthetic method to handle situations like escalated visibility.
235 if (!method->IsSynthetic()) {
236 break;
237 }
238 }
239 return result;
240}
241
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800242jobject Class_getDeclaredConstructorOrMethod(JNIEnv* env, jclass javaClass, jstring javaName,
243 jobjectArray javaArgs) {
Elliott Hughes418d20f2011-09-22 14:00:39 -0700244 Class* c = Decode<Class*>(env, javaClass);
Elliott Hughes95572412011-12-13 18:14:20 -0800245 std::string name(Decode<String*>(env, javaName)->ToModifiedUtf8());
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800246 ObjectArray<Class>* arg_array = Decode<ObjectArray<Class>*>(env, javaArgs);
Brian Carlstrom3a7b4f22011-09-17 15:01:57 -0700247
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800248 Method* m = FindConstructorOrMethodInArray(c->GetDirectMethods(), name, arg_array);
Jesse Wilson8ea36f82011-11-21 10:35:06 -0500249 if (m == NULL) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800250 m = FindConstructorOrMethodInArray(c->GetVirtualMethods(), name, arg_array);
Brian Carlstrom3a7b4f22011-09-17 15:01:57 -0700251 }
252
Jesse Wilson8ea36f82011-11-21 10:35:06 -0500253 if (m != NULL) {
Jesse Wilson8ea36f82011-11-21 10:35:06 -0500254 return AddLocalReference<jobject>(env, m);
255 } else {
256 return NULL;
Brian Carlstrom3a7b4f22011-09-17 15:01:57 -0700257 }
Brian Carlstrom3a7b4f22011-09-17 15:01:57 -0700258}
259
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800260jobject Class_getDeclaredFieldNative(JNIEnv* env, jclass jklass, jobject jname) {
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700261 Class* klass = Decode<Class*>(env, jklass);
262 DCHECK(klass->IsClass());
263 String* name = Decode<String*>(env, jname);
Elliott Hughesdbb40792011-11-18 17:05:22 -0800264 DCHECK(name->GetClass()->IsStringClass());
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700265
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800266 FieldHelper fh;
Elliott Hughes80609252011-09-23 17:24:51 -0700267 for (size_t i = 0; i < klass->NumInstanceFields(); ++i) {
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700268 Field* f = klass->GetInstanceField(i);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800269 fh.ChangeField(f);
270 if (name->Equals(fh.GetName())) {
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700271 return AddLocalReference<jclass>(env, f);
272 }
273 }
274 for (size_t i = 0; i < klass->NumStaticFields(); ++i) {
275 Field* f = klass->GetStaticField(i);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800276 fh.ChangeField(f);
277 if (name->Equals(fh.GetName())) {
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700278 return AddLocalReference<jclass>(env, f);
279 }
280 }
281 return NULL;
282}
283
Elliott Hughes6bdc3b22011-09-16 19:24:10 -0700284jstring Class_getNameNative(JNIEnv* env, jobject javaThis) {
Ian Rogersf45b1542012-02-03 18:03:48 -0800285 ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable);
Elliott Hughes6bdc3b22011-09-16 19:24:10 -0700286 Class* c = Decode<Class*>(env, javaThis);
Ian Rogersd418eda2012-01-30 12:14:28 -0800287 return AddLocalReference<jstring>(env, c->ComputeName());
Elliott Hughes6bdc3b22011-09-16 19:24:10 -0700288}
289
Elliott Hughesdd8df692011-09-23 14:42:41 -0700290jboolean Class_isAssignableFrom(JNIEnv* env, jobject javaLhs, jclass javaRhs) {
Brian Carlstromb82b6872011-10-26 17:18:07 -0700291 ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable);
Elliott Hughesdd8df692011-09-23 14:42:41 -0700292 Class* lhs = Decode<Class*>(env, javaLhs);
293 Class* rhs = Decode<Class*>(env, javaRhs);
294 if (rhs == NULL) {
295 Thread::Current()->ThrowNewException("Ljava/lang/NullPointerException;", "class == null");
296 return JNI_FALSE;
297 }
298 return lhs->IsAssignableFrom(rhs) ? JNI_TRUE : JNI_FALSE;
299}
300
301jboolean Class_isInstance(JNIEnv* env, jobject javaClass, jobject javaObject) {
302 Class* c = Decode<Class*>(env, javaClass);
303 Object* o = Decode<Object*>(env, javaObject);
304 if (o == NULL) {
305 return JNI_FALSE;
306 }
Brian Carlstrom5d40f182011-09-26 22:29:18 -0700307 return o->InstanceOf(c) ? JNI_TRUE : JNI_FALSE;
Elliott Hughesdd8df692011-09-23 14:42:41 -0700308}
309
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700310// Validate method/field access.
Ian Rogersd418eda2012-01-30 12:14:28 -0800311static bool CheckMemberAccess(const Class* access_from, Class* access_to, uint32_t member_flags) {
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700312 // quick accept for public access */
313 if (member_flags & kAccPublic) {
314 return true;
315 }
316
317 // quick accept for access from same class
318 if (access_from == access_to) {
319 return true;
320 }
321
322 // quick reject for private access from another class
323 if (member_flags & kAccPrivate) {
324 return false;
325 }
326
327 // Semi-quick test for protected access from a sub-class, which may or
328 // may not be in the same package.
329 if (member_flags & kAccProtected) {
330 if (access_from->IsSubClass(access_to)) {
331 return true;
332 }
333 }
334
335 // Allow protected and private access from other classes in the same
336 return access_from->IsInSamePackage(access_to);
337}
338
339jobject Class_newInstanceImpl(JNIEnv* env, jobject javaThis) {
Brian Carlstromb82b6872011-10-26 17:18:07 -0700340 ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable);
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700341 Class* c = Decode<Class*>(env, javaThis);
342 if (c->IsPrimitive() || c->IsInterface() || c->IsArrayClass() || c->IsAbstract()) {
Elliott Hughes5cb5ad22011-10-02 12:13:39 -0700343 Thread::Current()->ThrowNewExceptionF("Ljava/lang/InstantiationException;",
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800344 "Class %s can not be instantiated", PrettyDescriptor(ClassHelper(c).GetDescriptor()).c_str());
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700345 return NULL;
346 }
347
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700348 if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(c, true)) {
349 return NULL;
350 }
351
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700352 Method* init = c->FindDirectMethod("<init>", "()V");
353 if (init == NULL) {
Elliott Hughes5cb5ad22011-10-02 12:13:39 -0700354 Thread::Current()->ThrowNewExceptionF("Ljava/lang/InstantiationException;",
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800355 "Class %s has no default <init>()V constructor", PrettyDescriptor(ClassHelper(c).GetDescriptor()).c_str());
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700356 return NULL;
357 }
358
359 // Verify access from the call site.
360 //
361 // First, make sure the method invoking Class.newInstance() has permission
362 // to access the class.
363 //
364 // Second, make sure it has permission to invoke the constructor. The
365 // constructor must be public or, if the caller is in the same package,
366 // have package scope.
367 // TODO: need SmartFrame (Thread::WalkStack-like iterator).
368 Frame frame = Thread::Current()->GetTopOfStack();
369 frame.Next();
370 frame.Next();
371 Method* caller_caller = frame.GetMethod();
372 Class* caller_class = caller_caller->GetDeclaringClass();
373
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800374 ClassHelper caller_ch(caller_class);
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700375 if (!caller_class->CanAccess(c)) {
Elliott Hughes5cb5ad22011-10-02 12:13:39 -0700376 Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalAccessException;",
377 "Class %s is not accessible from class %s",
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800378 PrettyDescriptor(ClassHelper(c).GetDescriptor()).c_str(),
379 PrettyDescriptor(caller_ch.GetDescriptor()).c_str());
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700380 return NULL;
381 }
382 if (!CheckMemberAccess(caller_class, init->GetDeclaringClass(), init->GetAccessFlags())) {
Elliott Hughes5cb5ad22011-10-02 12:13:39 -0700383 Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalAccessException;",
384 "%s is not accessible from class %s",
385 PrettyMethod(init).c_str(),
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800386 PrettyDescriptor(caller_ch.GetDescriptor()).c_str());
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700387 return NULL;
388 }
389
390 Object* new_obj = c->AllocObject();
391 if (new_obj == NULL) {
392 DCHECK(Thread::Current()->IsExceptionPending());
393 return NULL;
394 }
395
396 // invoke constructor; unlike reflection calls, we don't wrap exceptions
397 jclass jklass = AddLocalReference<jclass>(env, c);
398 jmethodID mid = EncodeMethod(init);
399 return env->NewObject(jklass, mid);
400}
401
Elliott Hughesd369bb72011-09-12 14:41:14 -0700402static JNINativeMethod gMethods[] = {
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700403 NATIVE_METHOD(Class, classForName, "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;"),
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800404 NATIVE_METHOD(Class, getAnnotationDirectoryOffset, "()I"),
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800405 NATIVE_METHOD(Class, getDeclaredConstructorOrMethod, "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Member;"),
406 NATIVE_METHOD(Class, getDeclaredConstructors, "(Z)[Ljava/lang/reflect/Constructor;"),
407 NATIVE_METHOD(Class, getDeclaredFieldNative, "(Ljava/lang/String;)Ljava/lang/reflect/Field;"),
408 NATIVE_METHOD(Class, getDeclaredFields, "(Z)[Ljava/lang/reflect/Field;"),
409 NATIVE_METHOD(Class, getDeclaredMethods, "(Z)[Ljava/lang/reflect/Method;"),
Jesse Wilson6bf19152011-09-29 13:12:33 -0400410 NATIVE_METHOD(Class, getDex, "()Lcom/android/dex/Dex;"),
Elliott Hughes6bdc3b22011-09-16 19:24:10 -0700411 NATIVE_METHOD(Class, getNameNative, "()Ljava/lang/String;"),
Elliott Hughesdd8df692011-09-23 14:42:41 -0700412 NATIVE_METHOD(Class, isAssignableFrom, "(Ljava/lang/Class;)Z"),
413 NATIVE_METHOD(Class, isInstance, "(Ljava/lang/Object;)Z"),
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700414 NATIVE_METHOD(Class, newInstanceImpl, "()Ljava/lang/Object;"),
Elliott Hughesd369bb72011-09-12 14:41:14 -0700415};
416
417} // namespace
418
419void register_java_lang_Class(JNIEnv* env) {
420 jniRegisterNativeMethods(env, "java/lang/Class", gMethods, NELEM(gMethods));
421}
422
423} // namespace art