blob: eca6c325740c4ba9dffdb280dca9921eaa6f8542 [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
Elliott Hugheseac76672012-05-24 21:56:51 -070017#include "class_linker.h"
Jesse Wilson95caa792011-10-12 18:14:17 -040018#include "jni_internal.h"
19#include "object.h"
Jesse Wilson95caa792011-10-12 18:14:17 -040020
21namespace art {
22
Jesse Wilson95caa792011-10-12 18:14:17 -040023static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName, jobjectArray javaInterfaces, jobject javaLoader, jobjectArray javaMethods, jobjectArray javaThrows) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080024 // Allocates Class so transition thread state to runnable
Elliott Hughes34e06962012-04-09 13:55:55 -070025 ScopedThreadStateChange tsc(Thread::Current(), kRunnable);
Jesse Wilson95caa792011-10-12 18:14:17 -040026 String* name = Decode<String*>(env, javaName);
27 ObjectArray<Class>* interfaces = Decode<ObjectArray<Class>*>(env, javaInterfaces);
28 ClassLoader* loader = Decode<ClassLoader*>(env, javaLoader);
29 ObjectArray<Method>* methods = Decode<ObjectArray<Method>*>(env, javaMethods);
Ian Rogers466bb252011-10-14 03:29:56 -070030 ObjectArray<ObjectArray<Class> >* throws = Decode<ObjectArray<ObjectArray<Class> >*>(env, javaThrows);
Jesse Wilson95caa792011-10-12 18:14:17 -040031 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
32 Class* result = class_linker->CreateProxyClass(name, interfaces, loader, methods, throws);
33 return AddLocalReference<jclass>(env, result);
34}
35
Elliott Hughes0512f022012-03-15 22:10:52 -070036static JNINativeMethod gMethods[] = {
Jesse Wilson95caa792011-10-12 18:14:17 -040037 NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/Method;[[Ljava/lang/Class;)Ljava/lang/Class;"),
38};
39
Jesse Wilson95caa792011-10-12 18:14:17 -040040void register_java_lang_reflect_Proxy(JNIEnv* env) {
Elliott Hugheseac76672012-05-24 21:56:51 -070041 REGISTER_NATIVE_METHODS("java/lang/reflect/Proxy");
Jesse Wilson95caa792011-10-12 18:14:17 -040042}
43
44} // namespace art