blob: 5516105abefbcfd85d4a9c7028ba9ee563339167 [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
Andreas Gampe027444b2017-03-31 12:49:07 -070019#include "android-base/logging.h"
20#include "android-base/macros.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080021#include "android-base/stringprintf.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080022#include "jni.h"
Andreas Gampe5e03a302017-03-13 13:10:00 -070023#include "jvmti.h"
Andreas Gampe027444b2017-03-31 12:49:07 -070024#include "scoped_utf_chars.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080025
Andreas Gampe3f46c962017-03-30 10:26:59 -070026// Test infrastructure
27#include "jvmti_helper.h"
28#include "test_env.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080029
30namespace art {
31namespace Test929Search {
32
33extern "C" JNIEXPORT void JNICALL Java_Main_addToBootClassLoader(
34 JNIEnv* env, jclass Main_klass ATTRIBUTE_UNUSED, jstring segment) {
35 ScopedUtfChars utf(env, segment);
36 if (utf.c_str() == nullptr) {
37 return;
38 }
39 jvmtiError result = jvmti_env->AddToBootstrapClassLoaderSearch(utf.c_str());
Andreas Gampe3f46c962017-03-30 10:26:59 -070040 JvmtiErrorToException(env, jvmti_env, result);
Andreas Gampece7732b2017-01-17 15:50:26 -080041}
42
43extern "C" JNIEXPORT void JNICALL Java_Main_addToSystemClassLoader(
44 JNIEnv* env, jclass Main_klass ATTRIBUTE_UNUSED, jstring segment) {
45 ScopedUtfChars utf(env, segment);
46 if (utf.c_str() == nullptr) {
47 return;
48 }
49 jvmtiError result = jvmti_env->AddToSystemClassLoaderSearch(utf.c_str());
Andreas Gampe3f46c962017-03-30 10:26:59 -070050 JvmtiErrorToException(env, jvmti_env, result);
Andreas Gampece7732b2017-01-17 15:50:26 -080051}
52
53} // namespace Test929Search
54} // namespace art