• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "class_linker.h"
18 #include "jni_internal.h"
19 #include "mirror/class_loader.h"
20 #include "mirror/object_array.h"
21 #include "mirror/string.h"
22 #include "scoped_thread_state_change.h"
23 
24 namespace art {
25 
Proxy_generateProxy(JNIEnv * env,jclass,jstring javaName,jobjectArray javaInterfaces,jobject javaLoader,jobjectArray javaMethods,jobjectArray javaThrows)26 static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName,
27                                   jobjectArray javaInterfaces, jobject javaLoader,
28                                   jobjectArray javaMethods, jobjectArray javaThrows) {
29   ScopedObjectAccess soa(env);
30   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::ArtMethod>* methods =
35       soa.Decode<mirror::ObjectArray<mirror::ArtMethod>*>(javaMethods);
36   mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >* throws =
37       soa.Decode<mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >*>(javaThrows);
38   ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
39   mirror::Class* result = class_linker->CreateProxyClass(name, interfaces, loader, methods, throws);
40   return soa.AddLocalReference<jclass>(result);
41 }
42 
43 static JNINativeMethod gMethods[] = {
44   NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/ArtMethod;[[Ljava/lang/Class;)Ljava/lang/Class;"),
45 };
46 
register_java_lang_reflect_Proxy(JNIEnv * env)47 void register_java_lang_reflect_Proxy(JNIEnv* env) {
48   REGISTER_NATIVE_METHODS("java/lang/reflect/Proxy");
49 }
50 
51 }  // namespace art
52