Alex Light | 6fa7b81 | 2017-06-16 09:04:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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> |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 18 | |
| 19 | #include <cstdio> |
Alex Light | 6fa7b81 | 2017-06-16 09:04:29 -0700 | [diff] [blame] | 20 | #include <memory> |
Alex Light | 6fa7b81 | 2017-06-16 09:04:29 -0700 | [diff] [blame] | 21 | |
| 22 | #include "android-base/logging.h" |
| 23 | #include "android-base/stringprintf.h" |
| 24 | |
| 25 | #include "jni.h" |
| 26 | #include "jvmti.h" |
| 27 | #include "scoped_local_ref.h" |
| 28 | |
| 29 | // Test infrastructure |
| 30 | #include "jni_binder.h" |
| 31 | #include "jni_helper.h" |
| 32 | #include "jvmti_helper.h" |
| 33 | #include "test_env.h" |
| 34 | #include "ti_macros.h" |
| 35 | |
| 36 | namespace art { |
| 37 | namespace Test992SourceFile { |
| 38 | |
| 39 | extern "C" JNIEXPORT |
| 40 | jstring JNICALL Java_art_Test992_getSourceFileName(JNIEnv* env, |
| 41 | jclass klass ATTRIBUTE_UNUSED, |
| 42 | jclass target) { |
| 43 | char* file = nullptr; |
| 44 | if (JvmtiErrorToException(env, jvmti_env, jvmti_env->GetSourceFileName(target, &file))) { |
| 45 | return nullptr; |
| 46 | } |
| 47 | jstring ret = env->NewStringUTF(file); |
| 48 | jvmti_env->Deallocate(reinterpret_cast<unsigned char*>(file)); |
| 49 | return ret; |
| 50 | } |
| 51 | |
Alex Light | 89f33b8 | 2017-10-23 16:37:03 -0700 | [diff] [blame] | 52 | extern "C" JNIEXPORT |
| 53 | jstring JNICALL Java_art_Test992_getSourceDebugExtension(JNIEnv* env, |
| 54 | jclass klass ATTRIBUTE_UNUSED, |
| 55 | jclass target) { |
| 56 | char* ext = nullptr; |
| 57 | if (JvmtiErrorToException(env, jvmti_env, jvmti_env->GetSourceDebugExtension(target, &ext))) { |
| 58 | return nullptr; |
| 59 | } |
| 60 | jstring ret = env->NewStringUTF(ext); |
| 61 | jvmti_env->Deallocate(reinterpret_cast<unsigned char*>(ext)); |
| 62 | return ret; |
| 63 | } |
| 64 | |
Alex Light | 6fa7b81 | 2017-06-16 09:04:29 -0700 | [diff] [blame] | 65 | } // namespace Test992SourceFile |
| 66 | } // namespace art |
| 67 | |