Andreas Gampe | ce7732b | 2017-01-17 15:50:26 -0800 | [diff] [blame] | 1 | /* |
| 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 Gampe | 027444b | 2017-03-31 12:49:07 -0700 | [diff] [blame] | 19 | #include "android-base/logging.h" |
| 20 | #include "android-base/macros.h" |
Andreas Gampe | ce7732b | 2017-01-17 15:50:26 -0800 | [diff] [blame] | 21 | #include "android-base/stringprintf.h" |
Andreas Gampe | ce7732b | 2017-01-17 15:50:26 -0800 | [diff] [blame] | 22 | #include "jni.h" |
Andreas Gampe | 5e03a30 | 2017-03-13 13:10:00 -0700 | [diff] [blame] | 23 | #include "jvmti.h" |
Andreas Gampe | 027444b | 2017-03-31 12:49:07 -0700 | [diff] [blame] | 24 | #include "scoped_utf_chars.h" |
Andreas Gampe | ce7732b | 2017-01-17 15:50:26 -0800 | [diff] [blame] | 25 | |
Andreas Gampe | 3f46c96 | 2017-03-30 10:26:59 -0700 | [diff] [blame] | 26 | // Test infrastructure |
| 27 | #include "jvmti_helper.h" |
| 28 | #include "test_env.h" |
Andreas Gampe | ce7732b | 2017-01-17 15:50:26 -0800 | [diff] [blame] | 29 | |
| 30 | namespace art { |
| 31 | namespace Test929Search { |
| 32 | |
| 33 | extern "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 Gampe | 3f46c96 | 2017-03-30 10:26:59 -0700 | [diff] [blame] | 40 | JvmtiErrorToException(env, jvmti_env, result); |
Andreas Gampe | ce7732b | 2017-01-17 15:50:26 -0800 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | extern "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 Gampe | 3f46c96 | 2017-03-30 10:26:59 -0700 | [diff] [blame] | 50 | JvmtiErrorToException(env, jvmti_env, result); |
Andreas Gampe | ce7732b | 2017-01-17 15:50:26 -0800 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | } // namespace Test929Search |
| 54 | } // namespace art |