blob: dc3f3144dca7e9de57ce20550dbec09898038493 [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 }
38 return access_flags & kAccMethodFlagsMask;
39}
40
Jesse Wilsond2e0f902011-09-30 15:50:08 -040041jint Method_getProtoIndex(JNIEnv* env, jclass, jclass javaDeclaringClass, jobject jmethod, jint slot) {
42 Method* m = Decode<Object*>(env, jmethod)->AsMethod();
43 return m->GetProtoIdx();
44}
45
Elliott Hughes2a20cfd2011-09-23 19:30:41 -070046jobject Method_invokeNative(JNIEnv* env, jobject javaMethod, jobject javaReceiver, jobject javaArgs, jclass, jobject javaParams, jclass, jint, jboolean) {
47 return InvokeMethod(env, javaMethod, javaReceiver, javaArgs, javaParams);
Elliott Hughes418d20f2011-09-22 14:00:39 -070048}
49
Brian Carlstromf867b6f2011-09-16 12:17:25 -070050static JNINativeMethod gMethods[] = {
Brian Carlstromf867b6f2011-09-16 12:17:25 -070051 NATIVE_METHOD(Method, getMethodModifiers, "(Ljava/lang/Class;Ljava/lang/reflect/AccessibleObject;I)I"),
Jesse Wilsond2e0f902011-09-30 15:50:08 -040052 NATIVE_METHOD(Method, getProtoIndex, "(Ljava/lang/Class;Ljava/lang/reflect/AccessibleObject;I)I"),
Elliott Hughes418d20f2011-09-22 14:00:39 -070053 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 -070054};
55
56} // namespace
57
58void register_java_lang_reflect_Method(JNIEnv* env) {
59 jniRegisterNativeMethods(env, "java/lang/reflect/Method", gMethods, NELEM(gMethods));
60}
61
62} // namespace art