1 /*
2  * Copyright (C) 2016 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 <string>
18 
19 #include "nativeloader/native_loader.h"
20 
21 #include "core_jni_helpers.h"
22 
23 
createClassloaderNamespace_native(JNIEnv * env,jobject clazz,jobject classLoader,jint targetSdkVersion,jstring librarySearchPath,jstring libraryPermittedPath,jboolean isShared,jstring dexPath,jstring sonameList)24 static jstring createClassloaderNamespace_native(JNIEnv* env,
25                                               jobject clazz,
26                                               jobject classLoader,
27                                               jint targetSdkVersion,
28                                               jstring librarySearchPath,
29                                               jstring libraryPermittedPath,
30                                               jboolean isShared,
31                                               jstring dexPath,
32                                               jstring sonameList) {
33     return android::CreateClassLoaderNamespace(env, targetSdkVersion,
34                                                classLoader, isShared == JNI_TRUE,
35                                                dexPath,
36                                                librarySearchPath,
37                                                libraryPermittedPath,
38                                                sonameList);
39 }
40 
41 static const JNINativeMethod g_methods[] = {
42     { "createClassloaderNamespace",
43       "(Ljava/lang/ClassLoader;ILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
44       reinterpret_cast<void*>(createClassloaderNamespace_native) },
45 };
46 
47 static const char* const kClassLoaderFactoryPathName = "com/android/internal/os/ClassLoaderFactory";
48 
49 namespace android
50 {
51 
register_com_android_internal_os_ClassLoaderFactory(JNIEnv * env)52 int register_com_android_internal_os_ClassLoaderFactory(JNIEnv* env) {
53     return RegisterMethodsOrDie(env, kClassLoaderFactoryPathName, g_methods, NELEM(g_methods));
54 }
55 
56 } // namespace android
57