blob: e36078fc16231594fa26b5a3cb9b8aeb8bac484a [file] [log] [blame]
Brian Carlstromf867b6f2011-09-16 12:17:25 -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"
19#include "object.h"
Elliott Hughes418d20f2011-09-22 14:00:39 -070020#include "reflection.h"
Brian Carlstromf867b6f2011-09-16 12:17:25 -070021
22#include "JniConstants.h" // Last to avoid problems with LOG redefinition.
23
24namespace art {
25
26namespace {
27
Elliott Hughes2a20cfd2011-09-23 19:30:41 -070028jint 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 Carlstromf867b6f2011-09-16 12:17:25 -070034 access_flags &= ~kAccSynchronized;
35 if ((access_flags & kAccDeclaredSynchronized) != 0) {
36 access_flags |= kAccSynchronized;
37 }
Elliott Hughes582a7d12011-10-10 18:38:42 -070038
39 return access_flags & kAccJavaFlagsMask;
Brian Carlstromf867b6f2011-09-16 12:17:25 -070040}
41
Jesse Wilsond2e0f902011-09-30 15:50:08 -040042jint Method_getProtoIndex(JNIEnv* env, jclass, jclass javaDeclaringClass, jobject jmethod, jint slot) {
43 Method* m = Decode<Object*>(env, jmethod)->AsMethod();
44 return m->GetProtoIdx();
45}
46
Elliott Hughes2a20cfd2011-09-23 19:30:41 -070047jobject Method_invokeNative(JNIEnv* env, jobject javaMethod, jobject javaReceiver, jobject javaArgs, jclass, jobject javaParams, jclass, jint, jboolean) {
48 return InvokeMethod(env, javaMethod, javaReceiver, javaArgs, javaParams);
Elliott Hughes418d20f2011-09-22 14:00:39 -070049}
50
Brian Carlstromf867b6f2011-09-16 12:17:25 -070051static JNINativeMethod gMethods[] = {
Brian Carlstromf867b6f2011-09-16 12:17:25 -070052 NATIVE_METHOD(Method, getMethodModifiers, "(Ljava/lang/Class;Ljava/lang/reflect/AccessibleObject;I)I"),
Jesse Wilsond2e0f902011-09-30 15:50:08 -040053 NATIVE_METHOD(Method, getProtoIndex, "(Ljava/lang/Class;Ljava/lang/reflect/AccessibleObject;I)I"),
Elliott Hughes418d20f2011-09-22 14:00:39 -070054 NATIVE_METHOD(Method, invokeNative, "(Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;[Ljava/lang/Class;Ljava/lang/Class;IZ)Ljava/lang/Object;"),
Brian Carlstromf867b6f2011-09-16 12:17:25 -070055};
56
57} // namespace
58
59void register_java_lang_reflect_Method(JNIEnv* env) {
60 jniRegisterNativeMethods(env, "java/lang/reflect/Method", gMethods, NELEM(gMethods));
61}
62
63} // namespace art