blob: 437779a5f495cb1bc81d31fd8438a15412821d3d [file] [log] [blame]
Andreas Gampe8da6d032016-10-31 19:31:03 -07001/*
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
17#include "heaps.h"
18
19#include <stdio.h>
20#include <string.h>
21
22#include "base/macros.h"
23#include "jni.h"
24#include "openjdkjvmti/jvmti.h"
25
26#include "ti-agent/common_load.h"
27
28namespace art {
29namespace Test913Heaps {
30
31extern "C" JNIEXPORT void JNICALL Java_Main_forceGarbageCollection(JNIEnv* env ATTRIBUTE_UNUSED,
32 jclass klass ATTRIBUTE_UNUSED) {
33 jvmtiError ret = jvmti_env->ForceGarbageCollection();
34 if (ret != JVMTI_ERROR_NONE) {
35 char* err;
36 jvmti_env->GetErrorName(ret, &err);
37 printf("Error forcing a garbage collection: %s\n", err);
38 }
39}
40
41// Don't do anything
42jint OnLoad(JavaVM* vm,
43 char* options ATTRIBUTE_UNUSED,
44 void* reserved ATTRIBUTE_UNUSED) {
45 if (vm->GetEnv(reinterpret_cast<void**>(&jvmti_env), JVMTI_VERSION_1_0)) {
46 printf("Unable to get jvmti env!\n");
47 return 1;
48 }
49 return 0;
50}
51
52} // namespace Test913Heaps
53} // namespace art