Skip to content

Commit af1662a

Browse files
committed
JDK 25: added example of JEP 515
1 parent 45bc6e7 commit af1662a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

java-25/ProfilingTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.util.*;
2+
import java.util.stream.*;
3+
4+
/**
5+
* Compile: `javac ProfilingTest.java`
6+
* Test AOT cache with two-step:
7+
* * Record mode: `java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconf ProfilingTest`
8+
* * Create mode: `java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconf -XX:AOTCache=app.aot`
9+
* * Run with AOT cache: `java -XX:AOTCache=app.aot ProfilingTest`
10+
*/
11+
public class ProfilingTest {
12+
static String greeting(int n) {
13+
var words = List.of("Hello", "" + n, "world!");
14+
return words.stream()
15+
.filter(w -> !w.contains("0"))
16+
.collect(Collectors.joining(", "));
17+
}
18+
19+
public static void main(String... args) {
20+
for (int i = 0; i < 100_000; i++)
21+
greeting(i);
22+
System.out.println(greeting(0));
23+
}
24+
}

0 commit comments

Comments
 (0)