blob: 55ecd08a6828fa39fb75a2153589d9c96e142dec [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) {
28 String* name = Decode<String*>(env, javaName);
29 ObjectArray<Class>* interfaces = Decode<ObjectArray<Class>*>(env, javaInterfaces);
30 ClassLoader* loader = Decode<ClassLoader*>(env, javaLoader);
31 ObjectArray<Method>* methods = Decode<ObjectArray<Method>*>(env, javaMethods);
Ian Rogers466bb252011-10-14 03:29:56 -070032 ObjectArray<ObjectArray<Class> >* throws = Decode<ObjectArray<ObjectArray<Class> >*>(env, javaThrows);
Jesse Wilson95caa792011-10-12 18:14:17 -040033 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
34 Class* result = class_linker->CreateProxyClass(name, interfaces, loader, methods, throws);
35 return AddLocalReference<jclass>(env, result);
36}
37
38JNINativeMethod gMethods[] = {
39 NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/Method;[[Ljava/lang/Class;)Ljava/lang/Class;"),
40};
41
42} // namespace
43
44void register_java_lang_reflect_Proxy(JNIEnv* env) {
45 jniRegisterNativeMethods(env, "java/lang/reflect/Proxy", gMethods, NELEM(gMethods));
46}
47
48} // namespace art