< prev index next >
test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorOnOffTest.java
Print this page
@@ -29,14 +29,11 @@
* @build Frame
* @compile HeapMonitorOnOffTest.java
* @run main/othervm/native -agentlib:HeapMonitor MyPackage.HeapMonitorOnOffTest
*/
-import java.io.PrintStream;
-
public class HeapMonitorOnOffTest {
-
static {
try {
System.loadLibrary("HeapMonitor");
} catch (UnsatisfiedLinkError ule) {
System.err.println("Could not load HeapMonitor library");
@@ -44,11 +41,13 @@
+ System.getProperty("java.library.path"));
throw ule;
}
}
- public static int helper() {
+ private static int g_tmp[];
+
+ private static int helper() {
int sum = 0;
// Let us assume that the array is 24 bytes of memory.
for (int i = 0; i < 127000 / 6; i++) {
int tmp[] = new int[1];
// Force it to be kept.
@@ -56,32 +55,28 @@
sum += g_tmp[0];
}
return sum;
}
- public static void wrapper() {
+ private static void wrapper() {
int sum = 0;
for (int j = 0; j < 1000; j++) {
sum += helper();
}
System.out.println(sum);
}
- native static int checkFrames(Frame[] frames);
- native static int checkWipeOut(Frame[] frames);
- native static int enableSampling();
- native static int disableSampling();
-
- public static int cnt;
- public static int g_tmp[];
- public int array[];
+ private native static int checkFrames(Frame[] frames);
+ private native static int checkWipeOut(Frame[] frames);
+ private native static int enableSampling();
+ private native static int disableSampling();
public static void main(String[] args) {
Frame[] frames = new Frame[3];
- frames[0] = new Frame("helper", "()I", "HeapMonitorOnOffTest.java", 53);
- frames[1] = new Frame("wrapper", "()V", "HeapMonitorOnOffTest.java", 64);
- frames[2] = new Frame("main", "([Ljava/lang/String;)V", "HeapMonitorOnOffTest.java", 86);
+ frames[0] = new Frame("helper", "()I", "HeapMonitorOnOffTest.java", 52);
+ frames[1] = new Frame("wrapper", "()V", "HeapMonitorOnOffTest.java", 63);
+ frames[2] = new Frame("main", "([Ljava/lang/String;)V", "HeapMonitorOnOffTest.java", 81);
// Enable sampling and allocate.
enableSampling();
wrapper();
< prev index next >