blob: 547ce7b38d28670369f3e42ece88ee47c859c18f [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"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080019#include "mirror/class_loader.h"
20#include "mirror/object_array.h"
21#include "mirror/string.h"
Ian Rogers00f7d0e2012-07-19 15:28:27 -070022#include "scoped_thread_state_change.h"
Jesse Wilson95caa792011-10-12 18:14:17 -040023
24namespace art {
25
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080026static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName,
27 jobjectArray javaInterfaces, jobject javaLoader,
28 jobjectArray javaMethods, jobjectArray javaThrows) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -070029 ScopedObjectAccess soa(env);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080030 mirror::String* name = soa.Decode<mirror::String*>(javaName);
31 mirror::ObjectArray<mirror::Class>* interfaces =
32 soa.Decode<mirror::ObjectArray<mirror::Class>*>(javaInterfaces);
33 mirror::ClassLoader* loader = soa.Decode<mirror::ClassLoader*>(javaLoader);
34 mirror::ObjectArray<mirror::AbstractMethod>* methods =
35 soa.Decode<mirror::ObjectArray<mirror::AbstractMethod>*>(javaMethods);
36 mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >* throws =
37 soa.Decode<mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >*>(javaThrows);
Jesse Wilson95caa792011-10-12 18:14:17 -040038 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080039 mirror::Class* result = class_linker->CreateProxyClass(name, interfaces, loader, methods, throws);
Ian Rogers00f7d0e2012-07-19 15:28:27 -070040 return soa.AddLocalReference<jclass>(result);
Jesse Wilson95caa792011-10-12 18:14:17 -040041}
42
Elliott Hughes0512f022012-03-15 22:10:52 -070043static JNINativeMethod gMethods[] = {
Jesse Wilson95caa792011-10-12 18:14:17 -040044 NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/Method;[[Ljava/lang/Class;)Ljava/lang/Class;"),
45};
46
Jesse Wilson95caa792011-10-12 18:14:17 -040047void register_java_lang_reflect_Proxy(JNIEnv* env) {
Elliott Hugheseac76672012-05-24 21:56:51 -070048 REGISTER_NATIVE_METHODS("java/lang/reflect/Proxy");
Jesse Wilson95caa792011-10-12 18:14:17 -040049}
50
51} // namespace art