blob: 0d1c92be228ab45a0069e6dd291f0829b556805e [file] [log] [blame]
Andreas Gampe8da6d032016-10-31 19:31:03 -07001/*
2 * Copyright (C) 2016 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
17import java.util.ArrayList;
18
19public class Main {
20 public static void main(String[] args) throws Exception {
21 System.loadLibrary(args[1]);
22
23 doTest();
24 }
25
26 public static void doTest() throws Exception {
27 setupGcCallback();
28
29 enableGcTracking(true);
30 run();
31 enableGcTracking(false);
32 }
33
34 private static void run() {
35 printStats();
36 forceGarbageCollection();
37 printStats();
38 }
39
40 private static void printStats() {
41 System.out.println("---");
42 int s = getGcStarts();
43 int f = getGcFinishes();
44 System.out.println((s > 0) + " " + (f > 0));
45 }
46
47 private static native void setupGcCallback();
48 private static native void enableGcTracking(boolean enable);
49 private static native int getGcStarts();
50 private static native int getGcFinishes();
51 private static native void forceGarbageCollection();
52}