blob: 0553a9d007740226a1c4f2f175b6fa85abe4777d [file] [log] [blame]
Andreas Gampe50a4e492017-01-06 18:00:20 -08001/*
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
Andreas Gampe50a4e492017-01-06 18:00:20 -080017#include <stdio.h>
18
19#include "base/macros.h"
20#include "jni.h"
21#include "openjdkjvmti/jvmti.h"
22#include "ScopedLocalRef.h"
23
24#include "ti-agent/common_helper.h"
25#include "ti-agent/common_load.h"
26
27namespace art {
28namespace Test920Objects {
29
30extern "C" JNIEXPORT jlong JNICALL Java_Main_getObjectSize(
31 JNIEnv* env ATTRIBUTE_UNUSED, jclass klass ATTRIBUTE_UNUSED, jobject object) {
32 jlong size;
33
34 jvmtiError result = jvmti_env->GetObjectSize(object, &size);
35 if (result != JVMTI_ERROR_NONE) {
36 char* err;
37 jvmti_env->GetErrorName(result, &err);
38 printf("Failure running GetObjectSize: %s\n", err);
39 jvmti_env->Deallocate(reinterpret_cast<unsigned char*>(err));
40 return -1;
41 }
42
43 return size;
44}
45
46extern "C" JNIEXPORT jint JNICALL Java_Main_getObjectHashCode(
47 JNIEnv* env ATTRIBUTE_UNUSED, jclass klass ATTRIBUTE_UNUSED, jobject object) {
48 jint hash;
49
50 jvmtiError result = jvmti_env->GetObjectHashCode(object, &hash);
51 if (result != JVMTI_ERROR_NONE) {
52 char* err;
53 jvmti_env->GetErrorName(result, &err);
54 printf("Failure running GetObjectHashCode: %s\n", err);
55 jvmti_env->Deallocate(reinterpret_cast<unsigned char*>(err));
56 return -1;
57 }
58
59 return hash;
60}
61
Andreas Gampe50a4e492017-01-06 18:00:20 -080062} // namespace Test920Objects
63} // namespace art