| Alex Light | 1babae0 | 2017-02-01 15:35:34 -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 "base/macros.h" |
| 18 | #include "jni.h" |
| Andreas Gampe | 5e03a30 | 2017-03-13 13:10:00 -0700 | [diff] [blame] | 19 | #include "jvmti.h" |
| Alex Light | 1babae0 | 2017-02-01 15:35:34 -0800 | [diff] [blame] | 20 | #include "mirror/class-inl.h" |
| Alex Light | 1babae0 | 2017-02-01 15:35:34 -0800 | [diff] [blame] | 21 | #include "ScopedLocalRef.h" |
| 22 | |
| 23 | #include "ti-agent/common_helper.h" |
| 24 | #include "ti-agent/common_load.h" |
| 25 | |
| 26 | namespace art { |
| 27 | namespace Test944TransformClassloaders { |
| 28 | |
| 29 | |
| 30 | extern "C" JNIEXPORT jlong JNICALL Java_Main_getDexFilePointer(JNIEnv* env, jclass, jclass klass) { |
| 31 | if (Runtime::Current() == nullptr) { |
| 32 | env->ThrowNew(env->FindClass("java/lang/Exception"), |
| 33 | "We do not seem to be running in ART! Unable to get dex file."); |
| 34 | return 0; |
| 35 | } |
| 36 | ScopedObjectAccess soa(env); |
| 37 | // This sequence of casts must be the same as those done in |
| 38 | // runtime/native/dalvik_system_DexFile.cc in order to ensure that we get the same results. |
| 39 | return static_cast<jlong>(reinterpret_cast<uintptr_t>( |
| 40 | &soa.Decode<mirror::Class>(klass)->GetDexFile())); |
| 41 | } |
| 42 | |
| 43 | } // namespace Test944TransformClassloaders |
| 44 | } // namespace art |