blob: 81e3f169100f4e12e630f2ebcd5e40e501c29ce3 [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"
Ian Rogers365c1022012-06-22 15:05:28 -070018#include "class_loader.h"
Jesse Wilson95caa792011-10-12 18:14:17 -040019#include "jni_internal.h"
20#include "object.h"
Ian Rogers00f7d0e2012-07-19 15:28:27 -070021#include "scoped_thread_state_change.h"
Jesse Wilson95caa792011-10-12 18:14:17 -040022
23namespace art {
24
Jesse Wilson95caa792011-10-12 18:14:17 -040025static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName, jobjectArray javaInterfaces, jobject javaLoader, jobjectArray javaMethods, jobjectArray javaThrows) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -070026 ScopedObjectAccess soa(env);
27 String* name = soa.Decode<String*>(javaName);
28 ObjectArray<Class>* interfaces = soa.Decode<ObjectArray<Class>*>(javaInterfaces);
29 ClassLoader* loader = soa.Decode<ClassLoader*>(javaLoader);
30 ObjectArray<Method>* methods = soa.Decode<ObjectArray<Method>*>(javaMethods);
31 ObjectArray<ObjectArray<Class> >* throws = soa.Decode<ObjectArray<ObjectArray<Class> >*>(javaThrows);
Jesse Wilson95caa792011-10-12 18:14:17 -040032 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
33 Class* result = class_linker->CreateProxyClass(name, interfaces, loader, methods, throws);
Ian Rogers00f7d0e2012-07-19 15:28:27 -070034 return soa.AddLocalReference<jclass>(result);
Jesse Wilson95caa792011-10-12 18:14:17 -040035}
36
Elliott Hughes0512f022012-03-15 22:10:52 -070037static JNINativeMethod gMethods[] = {
Jesse Wilson95caa792011-10-12 18:14:17 -040038 NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/Method;[[Ljava/lang/Class;)Ljava/lang/Class;"),
39};
40
Jesse Wilson95caa792011-10-12 18:14:17 -040041void register_java_lang_reflect_Proxy(JNIEnv* env) {
Elliott Hugheseac76672012-05-24 21:56:51 -070042 REGISTER_NATIVE_METHODS("java/lang/reflect/Proxy");
Jesse Wilson95caa792011-10-12 18:14:17 -040043}
44
45} // namespace art