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" |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 20 | #include "object_utils.h" |
Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 21 | #include "reflection.h" |
Brian Carlstrom | f867b6f | 2011-09-16 12:17:25 -0700 | [diff] [blame] | 22 | |
| 23 | #include "JniConstants.h" // Last to avoid problems with LOG redefinition. |
| 24 | |
| 25 | namespace art { |
| 26 | |
| 27 | namespace { |
| 28 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 29 | jobject Method_invoke(JNIEnv* env, jobject javaMethod, jobject javaReceiver, jobject javaArgs) { |
| 30 | return InvokeMethod(env, javaMethod, javaReceiver, javaArgs); |
Brian Carlstrom | f867b6f | 2011-09-16 12:17:25 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 33 | jobject 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 Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 37 | } |
| 38 | |
Brian Carlstrom | f867b6f | 2011-09-16 12:17:25 -0700 | [diff] [blame] | 39 | static JNINativeMethod gMethods[] = { |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 40 | NATIVE_METHOD(Method, invoke, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;"), |
| 41 | NATIVE_METHOD(Method, getReturnTypeNative, "()Ljava/lang/Class;") |
Brian Carlstrom | f867b6f | 2011-09-16 12:17:25 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | } // namespace |
| 45 | |
| 46 | void register_java_lang_reflect_Method(JNIEnv* env) { |
| 47 | jniRegisterNativeMethods(env, "java/lang/reflect/Method", gMethods, NELEM(gMethods)); |
| 48 | } |
| 49 | |
| 50 | } // namespace art |