blob: 90d718d38a9be71a67a98cc8be1add36333954f0 [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"
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080020#include "object_utils.h"
Elliott Hughes418d20f2011-09-22 14:00:39 -070021#include "reflection.h"
Brian Carlstromf867b6f2011-09-16 12:17:25 -070022
23#include "JniConstants.h" // Last to avoid problems with LOG redefinition.
24
25namespace art {
26
27namespace {
28
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080029jobject Method_invoke(JNIEnv* env, jobject javaMethod, jobject javaReceiver, jobject javaArgs) {
30 return InvokeMethod(env, javaMethod, javaReceiver, javaArgs);
Brian Carlstromf867b6f2011-09-16 12:17:25 -070031}
32
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080033jobject Method_getReturnTypeNative(JNIEnv* env, jobject javaMethod) {
34 Method* m = Decode<Object*>(env, javaMethod)->AsMethod();
35 MethodHelper mh(m);
36 return AddLocalReference<jobject>(env, mh.GetReturnType());
Elliott Hughes418d20f2011-09-22 14:00:39 -070037}
38
Brian Carlstromf867b6f2011-09-16 12:17:25 -070039static JNINativeMethod gMethods[] = {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080040 NATIVE_METHOD(Method, invoke, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;"),
41 NATIVE_METHOD(Method, getReturnTypeNative, "()Ljava/lang/Class;")
Brian Carlstromf867b6f2011-09-16 12:17:25 -070042};
43
44} // namespace
45
46void register_java_lang_reflect_Method(JNIEnv* env) {
47 jniRegisterNativeMethods(env, "java/lang/reflect/Method", gMethods, NELEM(gMethods));
48}
49
50} // namespace art