blob: 28fe514556093fba6936c38456e03ea72349518a [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
17#include "jni_internal.h"
18#include "object.h"
19#include "class_linker.h"
20
21#include "JniConstants.h" // Last to avoid problems with LOG redefinition.
22
23namespace art {
24
25namespace {
26
27static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName, jobjectArray javaInterfaces, jobject javaLoader, jobjectArray javaMethods, jobjectArray javaThrows) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080028 // Allocates Class so transition thread state to runnable
29 ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable);
Jesse Wilson95caa792011-10-12 18:14:17 -040030 String* name = Decode<String*>(env, javaName);
31 ObjectArray<Class>* interfaces = Decode<ObjectArray<Class>*>(env, javaInterfaces);
32 ClassLoader* loader = Decode<ClassLoader*>(env, javaLoader);
33 ObjectArray<Method>* methods = Decode<ObjectArray<Method>*>(env, javaMethods);
Ian Rogers466bb252011-10-14 03:29:56 -070034 ObjectArray<ObjectArray<Class> >* throws = Decode<ObjectArray<ObjectArray<Class> >*>(env, javaThrows);
Jesse Wilson95caa792011-10-12 18:14:17 -040035 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
36 Class* result = class_linker->CreateProxyClass(name, interfaces, loader, methods, throws);
37 return AddLocalReference<jclass>(env, result);
38}
39
40JNINativeMethod gMethods[] = {
41 NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/Method;[[Ljava/lang/Class;)Ljava/lang/Class;"),
42};
43
44} // namespace
45
46void register_java_lang_reflect_Proxy(JNIEnv* env) {
47 jniRegisterNativeMethods(env, "java/lang/reflect/Proxy", gMethods, NELEM(gMethods));
48}
49
50} // namespace art