blob: d1c698491effac9f1820a4a75c650a3d324831ad [file] [log] [blame]
Andreas Gampece7732b2017-01-17 15:50:26 -08001/*
2 * Copyright (C) 2017 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 <inttypes.h>
18
19#include "android-base/stringprintf.h"
20#include "base/logging.h"
21#include "base/macros.h"
22#include "jni.h"
23#include "openjdkjvmti/jvmti.h"
24#include "ScopedUtfChars.h"
25
26#include "ti-agent/common_helper.h"
27#include "ti-agent/common_load.h"
28
29namespace art {
30namespace Test929Search {
31
32extern "C" JNIEXPORT void JNICALL Java_Main_addToBootClassLoader(
33 JNIEnv* env, jclass Main_klass ATTRIBUTE_UNUSED, jstring segment) {
34 ScopedUtfChars utf(env, segment);
35 if (utf.c_str() == nullptr) {
36 return;
37 }
38 jvmtiError result = jvmti_env->AddToBootstrapClassLoaderSearch(utf.c_str());
39 JvmtiErrorToException(env, result);
40}
41
42extern "C" JNIEXPORT void JNICALL Java_Main_addToSystemClassLoader(
43 JNIEnv* env, jclass Main_klass ATTRIBUTE_UNUSED, jstring segment) {
44 ScopedUtfChars utf(env, segment);
45 if (utf.c_str() == nullptr) {
46 return;
47 }
48 jvmtiError result = jvmti_env->AddToSystemClassLoaderSearch(utf.c_str());
49 JvmtiErrorToException(env, result);
50}
51
52} // namespace Test929Search
53} // namespace art