Skip to content

Commit ca1dcdf

Browse files
committed
jvmti api test
1 parent 8ac7f8f commit ca1dcdf

File tree

6 files changed

+505
-42
lines changed

6 files changed

+505
-42
lines changed
Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
11
import java.io.*;
22

33
public class ApiTest {
4-
static
5-
{
6-
System.loadLibrary("ApiTest");
7-
}
8-
9-
public static native void fprint(PrintWriter ps, String format, double x);
10-
11-
public static native void nativeMainMethod();
12-
13-
public static void main(String[] args) {
14-
ApiTest.nativeMainMethod();
15-
16-
double price = 44.95;
17-
double tax = 7.75;
18-
double amountDue = price * (1 + tax / 100);
19-
PrintWriter out = new PrintWriter(System.out);
20-
/* This call will throw an exception--note the %% */
21-
//ApiTest.fprint(out, "Amount due = %%8.2f\n", amountDue);
22-
//out.flush();
23-
24-
objectArrayTest();
25-
}
26-
27-
private static native int[][] initInt2DArray(int size);
28-
29-
30-
31-
public static void objectArrayTest() {
32-
int[][] i2arr = initInt2DArray(3);
33-
for (int i = 0; i < 3; i++) {
34-
for (int j = 0; j < 3; j++) {
35-
System.out.print(" " + i2arr[i][j]);
36-
}
37-
System.out.println();
38-
}
39-
}
4+
static {
5+
System.loadLibrary("ApiTest");
6+
}
7+
8+
public static native void fprint(PrintWriter ps, String format, double x);
9+
10+
public static native void nativeMainMethod();
11+
12+
public static void main(String[] args) {
13+
ApiTest.nativeMainMethod();
14+
15+
double price = 44.95;
16+
double tax = 7.75;
17+
double amountDue = price * (1 + tax / 100);
18+
PrintWriter out = new PrintWriter(System.out);
19+
/* This call will throw an exception--note the %% */
20+
//ApiTest.fprint(out, "Amount due = %%8.2f\n", amountDue);
21+
//out.flush();
22+
23+
objectArrayTest();
24+
}
25+
26+
private static native int[][] initInt2DArray(int size);
27+
28+
public static void objectArrayTest() {
29+
int[][] i2arr = initInt2DArray(3);
30+
for (int i = 0; i < 3; i++) {
31+
for (int j = 0; j < 3; j++) {
32+
System.out.print(" " + i2arr[i][j]);
33+
}
34+
System.out.println();
35+
}
36+
}
4037

4138
}

hotspot/my-test/jvmArgsFile.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@
1212

1313
#-Xrunhprof:help
1414
#-XX:NativeMemoryTracking=detail
15-
#-Djava.library.path=E:\openjdk\git\hotspot\my-test\build
15+
16+
-Djava.library.path=E:\openjdk\git\hotspot\my-test\build
1617

1718
#-Xbootclasspath/a:E:\openjdk\git\hotspot\my-test\build\myagent.jar
18-
#-agentlib:myagent=max=2 -version
19+
#-agentlib:myagent=max=2
20+
#-XX:SuppressErrorAt=\jvmtiEventController.cpp:634
21+
22+
-agentlib:myagent
1923

2024
#此参数会退出JVN
2125
#-XX:+CompileTheWorld
2226

23-
-Djava.class.path=E:\openjdk\git\hotspot\my-test\classes
27+
-Djava.class.path=E:\openjdk\git\hotspot\my-test\classes;E:\openjdk\git\hotspot\my-test\jvmti\api-test
2428

2529
#类名总是最后一个
26-
TestLauncher
30+
#TestLauncher
31+
ApiTest

0 commit comments

Comments
 (0)