forked from nipafx/demo-java-x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app-cds.sh
executable file
·75 lines (61 loc) · 1.92 KB
/
app-cds.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
set -e
source executables.sh
rm -rf app-cds
mkdir app-cds
if ! [ -e target/java-x.jar ]
then
printf "Building Maven project, so JAR is available...\n"
mvn clean install
fi
printf "\n--- RUN WITHOUT CDS ---\n\n"
time $java --enable-preview \
-jar target/java-x.jar
# Since Java 12, the JDK comes with an archive of the JDK classes
# and so it makes no sense to create a new one
#printf "\n--- RUN WITH CDS ---\n"
#printf "\n > create archive for default JDK classes\n"
#sudo $java -Xshare:dump
#printf "\n > use default archive\n"
#time $java --enable-preview -jar target/java-x.jar
#printf "\n > non-archived classes\n"
#$java --enable-preview \
# -Xlog:class+load \
# -jar target/java-x.jar \
#| grep -v "shared objects file"
printf "\n--- RUN WITH APPLICATION CDS ---\n"
printf "\n > record used classes\n"
$java --enable-preview \
-XX:DumpLoadedClassList=app-cds/classes.lst \
-jar target/java-x.jar
printf "\n > create archive for recorded classes\n"
$java --enable-preview \
-Xshare:dump \
-XX:SharedClassListFile=app-cds/classes.lst \
-XX:SharedArchiveFile=app-cds/app.jsa \
--class-path target/java-x.jar
printf "\n > use created archive\n"
time $java --enable-preview \
-XX:SharedArchiveFile=app-cds/app.jsa \
-jar target/java-x.jar \
printf "\n > non-archived classes\n"
$java --enable-preview \
-XX:SharedArchiveFile=app-cds/app.jsa \
-Xlog:class+load \
-jar target/java-x.jar \
| grep -v "shared objects file"
printf "\n--- RUN WITH DYNAMIC APP CDS ---\n"
printf "\n > run without CDS & create archive\n"
time $java --enable-preview \
-XX:ArchiveClassesAtExit=app-cds/dyn.jsa \
-jar target/java-x.jar
printf "\n > use created archive\n"
time $java --enable-preview \
-XX:SharedArchiveFile=app-cds/dyn.jsa \
-jar target/java-x.jar
printf "\n > non-archived classes\n"
$java --enable-preview \
-XX:SharedArchiveFile=app-cds/dyn.jsa \
-Xlog:class+load \
-jar target/java-x.jar \
| grep -v "shared objects file"