blob: f723ed223d4bb779e4d84bd12be03bb38799b257 [file] [log] [blame]
Jesse Wilson95caa792011-10-12 18:14:17 -04001/*
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
Andreas Gampe277ccbd2014-11-03 21:36:10 -080017#include "java_lang_reflect_Proxy.h"
18
Andreas Gampea14100c2017-04-24 15:09:56 -070019#include "nativehelper/jni_macros.h"
20
Elliott Hugheseac76672012-05-24 21:56:51 -070021#include "class_linker.h"
Vladimir Markoa3ad0cd2018-05-04 10:06:38 +010022#include "jni/jni_internal.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080023#include "mirror/class_loader.h"
24#include "mirror/object_array.h"
25#include "mirror/string.h"
Andreas Gampe87583b32017-05-25 11:22:18 -070026#include "native_util.h"
Mathieu Chartier0795f232016-09-27 18:43:30 -070027#include "scoped_fast_native_object_access-inl.h"
Andreas Gampe90b936d2017-01-31 08:58:55 -080028#include "verify_object.h"
Jesse Wilson95caa792011-10-12 18:14:17 -040029
30namespace art {
31
Mathieu Chartier590fee92013-09-13 13:46:47 -070032static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring name, jobjectArray interfaces,
Nicolas Geoffray3a090922015-11-24 09:17:30 +000033 jobject loader, jobjectArray methods, jobjectArray throws) {
Ian Rogers53b8b092014-03-13 23:45:53 -070034 ScopedFastNativeObjectAccess soa(env);
Jesse Wilson95caa792011-10-12 18:14:17 -040035 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Nicolas Geoffray3a090922015-11-24 09:17:30 +000036 return soa.AddLocalReference<jclass>(class_linker->CreateProxyClass(
37 soa, name, interfaces, loader, methods, throws));
Jesse Wilson95caa792011-10-12 18:14:17 -040038}
39
Elliott Hughes0512f022012-03-15 22:10:52 -070040static JNINativeMethod gMethods[] = {
Igor Murashkin3b6f4402017-02-16 16:13:17 -080041 FAST_NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/Method;[[Ljava/lang/Class;)Ljava/lang/Class;"),
Jesse Wilson95caa792011-10-12 18:14:17 -040042};
43
Jesse Wilson95caa792011-10-12 18:14:17 -040044void register_java_lang_reflect_Proxy(JNIEnv* env) {
Elliott Hugheseac76672012-05-24 21:56:51 -070045 REGISTER_NATIVE_METHODS("java/lang/reflect/Proxy");
Jesse Wilson95caa792011-10-12 18:14:17 -040046}
47
48} // namespace art