150a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe/* 250a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * Copyright (C) 2013 The Android Open Source Project 350a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * 450a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * Licensed under the Apache License, Version 2.0 (the "License"); 550a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * you may not use this file except in compliance with the License. 650a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * You may obtain a copy of the License at 750a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * 850a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * http://www.apache.org/licenses/LICENSE-2.0 950a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * 1050a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * Unless required by applicable law or agreed to in writing, software 1150a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * distributed under the License is distributed on an "AS IS" BASIS, 1250a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1350a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * See the License for the specific language governing permissions and 1450a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe * limitations under the License. 1550a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe */ 1650a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 1750a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe#include <stdio.h> 1850a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 19027444b64dd52e1d2beea7aa525fbb8146a516bcAndreas Gampe#include "android-base/macros.h" 2050a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe#include "jni.h" 215e03a305edafb49a34b436d9a858281e53d390f2Andreas Gampe#include "jvmti.h" 22027444b64dd52e1d2beea7aa525fbb8146a516bcAndreas Gampe#include "scoped_local_ref.h" 2350a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 243f46c96568bef650ba6d9ce6ac8835d30877f243Andreas Gampe// Test infrastructure 253f46c96568bef650ba6d9ce6ac8835d30877f243Andreas Gampe#include "test_env.h" 2650a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 2750a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampenamespace art { 2850a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampenamespace Test920Objects { 2950a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 304665167ddc34008dfa78a2873685fe7a98772eabAndreas Gampeextern "C" JNIEXPORT jlong JNICALL Java_art_Test920_getObjectSize( 3150a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe JNIEnv* env ATTRIBUTE_UNUSED, jclass klass ATTRIBUTE_UNUSED, jobject object) { 3250a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe jlong size; 3350a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 3450a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe jvmtiError result = jvmti_env->GetObjectSize(object, &size); 3550a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe if (result != JVMTI_ERROR_NONE) { 3650a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe char* err; 3750a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe jvmti_env->GetErrorName(result, &err); 3850a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe printf("Failure running GetObjectSize: %s\n", err); 3950a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe jvmti_env->Deallocate(reinterpret_cast<unsigned char*>(err)); 4050a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe return -1; 4150a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe } 4250a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 4350a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe return size; 4450a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe} 4550a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 464665167ddc34008dfa78a2873685fe7a98772eabAndreas Gampeextern "C" JNIEXPORT jint JNICALL Java_art_Test920_getObjectHashCode( 4750a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe JNIEnv* env ATTRIBUTE_UNUSED, jclass klass ATTRIBUTE_UNUSED, jobject object) { 4850a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe jint hash; 4950a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 5050a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe jvmtiError result = jvmti_env->GetObjectHashCode(object, &hash); 5150a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe if (result != JVMTI_ERROR_NONE) { 5250a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe char* err; 5350a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe jvmti_env->GetErrorName(result, &err); 5450a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe printf("Failure running GetObjectHashCode: %s\n", err); 5550a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe jvmti_env->Deallocate(reinterpret_cast<unsigned char*>(err)); 5650a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe return -1; 5750a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe } 5850a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 5950a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe return hash; 6050a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe} 6150a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe 6250a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe} // namespace Test920Objects 6350a4e4964bd66993e19768fc3af5b960653df8edAndreas Gampe} // namespace art 64