blob: 7cb3c08dc34fc9d40790c08e0255fe667fa43fe1 [file] [log] [blame]
Alex Light1babae02017-02-01 15:35:34 -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 "base/macros.h"
18#include "jni.h"
Andreas Gampe5e03a302017-03-13 13:10:00 -070019#include "jvmti.h"
Alex Light1babae02017-02-01 15:35:34 -080020#include "mirror/class-inl.h"
Alex Light1babae02017-02-01 15:35:34 -080021#include "ScopedLocalRef.h"
22
23#include "ti-agent/common_helper.h"
24#include "ti-agent/common_load.h"
25
26namespace art {
27namespace Test944TransformClassloaders {
28
29
30extern "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