Brian Carlstrom | f867b6f | 2011-09-16 12:17:25 -0700 | [diff] [blame] | 1 | /* |
| 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" |
| 19 | #include "object.h" |
| 20 | |
| 21 | #include "JniConstants.h" // Last to avoid problems with LOG redefinition. |
| 22 | |
| 23 | namespace art { |
| 24 | |
| 25 | namespace { |
| 26 | |
| 27 | |
| 28 | // We move the DECLARED_SYNCHRONIZED flag into the SYNCHRONIZED |
| 29 | // position, because the callers of this function are trying to convey |
| 30 | // the "traditional" meaning of the flags to their callers. |
| 31 | uint32_t FixupMethodFlags(uint32_t access_flags) { |
| 32 | access_flags &= ~kAccSynchronized; |
| 33 | if ((access_flags & kAccDeclaredSynchronized) != 0) { |
| 34 | access_flags |= kAccSynchronized; |
| 35 | } |
| 36 | return access_flags & kAccMethodFlagsMask; |
| 37 | } |
| 38 | |
| 39 | jint Method_getMethodModifiers(JNIEnv* env, jclass, jclass javaDeclaringClass, jobject jmethod, jint slot) { |
| 40 | return FixupMethodFlags(Decode<Object*>(env, jmethod)->AsMethod()->GetAccessFlags()); |
| 41 | } |
| 42 | |
| 43 | static JNINativeMethod gMethods[] = { |
| 44 | //NATIVE_METHOD(Method, getAnnotation, "(Ljava/lang/Class;ILjava/lang/Class;)Ljava/lang/annotation/Annotation;"), |
| 45 | //NATIVE_METHOD(Method, getDeclaredAnnotations, "(Ljava/lang/Class;I)[Ljava/lang/annotation/Annotation;"), |
| 46 | //NATIVE_METHOD(Method, getDefaultValue, "(Ljava/lang/Class;I)Ljava/lang/Object;"), |
| 47 | NATIVE_METHOD(Method, getMethodModifiers, "(Ljava/lang/Class;Ljava/lang/reflect/AccessibleObject;I)I"), |
| 48 | //NATIVE_METHOD(Method, getParameterAnnotations, "(Ljava/lang/Class;I)[[Ljava/lang/annotation/Annotation;"), |
| 49 | //NATIVE_METHOD(Method, getSignatureAnnotation, "(Ljava/lang/Class;I)[Ljava/lang/Object;"), |
| 50 | //NATIVE_METHOD(Method, invokeNative, "(Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;[Ljava/lang/Class;Ljava/lang/Class;IZ)Ljava/lang/Object;"), |
| 51 | //NATIVE_METHOD(Method, isAnnotationPresent, "(Ljava/lang/Class;ILjava/lang/Class;)Z"), |
| 52 | }; |
| 53 | |
| 54 | } // namespace |
| 55 | |
| 56 | void register_java_lang_reflect_Method(JNIEnv* env) { |
| 57 | jniRegisterNativeMethods(env, "java/lang/reflect/Method", gMethods, NELEM(gMethods)); |
| 58 | } |
| 59 | |
| 60 | } // namespace art |