Skip to content

Commit 3f6137a

Browse files
committed
Fix Specify Class Initialization Explicitly guide rendering
1 parent 006f84e commit 3f6137a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/reference-manual/native-image/guides/specify-class-initialization.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,14 @@ The parser creates records and adds them to a `List<Talk>` collection.
119119
- Bootiful Spring Boot 3 by Josh Long
120120
./buildtime-parser 0.00s user 0.00s system 53% cpu 0.016 total
121121
```
122+
122123
Check the file size which should decrease to around 6.4M!
123-
```
124+
```bash
124125
du -sh buildtime-parser
125126
```
127+
126128
The file size change is because Native Image runs the static initializer at build time, parsing the text block, and persisting only the `Talk` records in the executable.
129+
127130
As a result, the majority of the scanning infrastructure does not become reachable when Native Image statically analyzes the application and is, therefore, not included in the executable.
128131

129132
Another valuable criterion for profiling applications more accurately is the number of instructions, which can be obtained using the [Linux `perf` profiler](../PerfProfiling.md).
@@ -164,6 +167,7 @@ Talks loaded using scanner:
164167

165168
This demonstrates how Native Image can shift work from runtime to build time: when the class is initialized at build time, the text block is parsed when the executable is being built and only the parsed objects are included.
166169
This not only makes the executable smaller in file size, but also faster to run: when the executable runs, the `Talk` records already exist and only need to be printed.
170+
<br>
167171

168172
To ensure native executables built with Native Image are as compatible as possible with the HotSpot behavior, application classes that cannot be safely initialized at build time, are initialized at runtime.
169173
You as a user, or a framework that you use, must explicitly request build-time initialization for certain classes to benefit from smaller file sizes and faster times to run.

0 commit comments

Comments
 (0)