blob: 101ebb9acd494eebcb5bad35429f139ad89f91cf [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
Andreas Gampe027444b2017-03-31 12:49:07 -070019#include "android-base/macros.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080020#include "jni.h"
Andreas Gampe5e03a302017-03-13 13:10:00 -070021#include "jvmti.h"
Andreas Gampe027444b2017-03-31 12:49:07 -070022#include "scoped_local_ref.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080023
Andreas Gampe3f46c962017-03-30 10:26:59 -070024// Test infrastructure
25#include "test_env.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080026
27namespace art {
28namespace Test920Objects {
29
Andreas Gampe46651672017-04-07 09:00:04 -070030extern "C" JNIEXPORT jlong JNICALL Java_art_Test920_getObjectSize(
Andreas Gampe50a4e492017-01-06 18:00:20 -080031 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
Andreas Gampe46651672017-04-07 09:00:04 -070046extern "C" JNIEXPORT jint JNICALL Java_art_Test920_getObjectHashCode(
Andreas Gampe50a4e492017-01-06 18:00:20 -080047 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