blob: baf8b2420759310b7c76771aa987b2fb1e81946d [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
Elliott Hugheseac76672012-05-24 21:56:51 -070019#include "class_linker.h"
Jesse Wilson95caa792011-10-12 18:14:17 -040020#include "jni_internal.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080021#include "mirror/class_loader.h"
22#include "mirror/object_array.h"
23#include "mirror/string.h"
Ian Rogers53b8b092014-03-13 23:45:53 -070024#include "scoped_fast_native_object_access.h"
Mathieu Chartier4e305412014-02-19 10:54:44 -080025#include "verify_object-inl.h"
Jesse Wilson95caa792011-10-12 18:14:17 -040026
27namespace art {
28
Mathieu Chartier590fee92013-09-13 13:46:47 -070029static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring name, jobjectArray interfaces,
30 jobject loader, jobjectArray methods, jobjectArray throws) {
Ian Rogers53b8b092014-03-13 23:45:53 -070031 ScopedFastNativeObjectAccess soa(env);
Jesse Wilson95caa792011-10-12 18:14:17 -040032 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Mathieu Chartier590fee92013-09-13 13:46:47 -070033 mirror::Class* result = class_linker->CreateProxyClass(soa, name, interfaces, loader, methods,
34 throws);
Ian Rogers00f7d0e2012-07-19 15:28:27 -070035 return soa.AddLocalReference<jclass>(result);
Jesse Wilson95caa792011-10-12 18:14:17 -040036}
37
Elliott Hughes0512f022012-03-15 22:10:52 -070038static JNINativeMethod gMethods[] = {
Ian Rogers53b8b092014-03-13 23:45:53 -070039 NATIVE_METHOD(Proxy, generateProxy, "!(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/ArtMethod;[[Ljava/lang/Class;)Ljava/lang/Class;"),
Jesse Wilson95caa792011-10-12 18:14:17 -040040};
41
Jesse Wilson95caa792011-10-12 18:14:17 -040042void register_java_lang_reflect_Proxy(JNIEnv* env) {
Elliott Hugheseac76672012-05-24 21:56:51 -070043 REGISTER_NATIVE_METHODS("java/lang/reflect/Proxy");
Jesse Wilson95caa792011-10-12 18:14:17 -040044}
45
46} // namespace art