blob: a988aac7e0699e0913f6f8f2142a1b64b6117ced [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
Elliott Hughes2a20cfd2011-09-23 19:30:41 -070041jobject 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 Hughes418d20f2011-09-22 14:00:39 -070043}
44
Brian Carlstromf867b6f2011-09-16 12:17:25 -070045static JNINativeMethod gMethods[] = {
Brian Carlstromf867b6f2011-09-16 12:17:25 -070046 NATIVE_METHOD(Method, getMethodModifiers, "(Ljava/lang/Class;Ljava/lang/reflect/AccessibleObject;I)I"),
Elliott Hughes418d20f2011-09-22 14:00:39 -070047 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 -070048};
49
50} // namespace
51
52void register_java_lang_reflect_Method(JNIEnv* env) {
53 jniRegisterNativeMethods(env, "java/lang/reflect/Method", gMethods, NELEM(gMethods));
54}
55
56} // namespace art