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