Elliotte Rusty Harold | e41cecf | 2022-04-26 12:07:27 +0000 | [diff] [blame] | 1 | # Ahead Of Time (AOT) compilation for the Java Virtual Machine (JVM) |
Christopher Hunt | c908fdb | 2021-02-18 11:10:42 +1100 | [diff] [blame] | 2 | |
| 3 | Ahead Of Time (AOT) compilation build tools such as those provided by [GraalVM's `native-image`](https://www.graalvm.org/reference-manual/native-image/) can require some configuration when using protobuf. |
Elliotte Rusty Harold | e41cecf | 2022-04-26 12:07:27 +0000 | [diff] [blame] | 4 | Protobuf for the JVM uses reflection, and some of its target classes are not possible to determine in advance. |
| 5 | This situation is unlikely to change. |
Christopher Hunt | c908fdb | 2021-02-18 11:10:42 +1100 | [diff] [blame] | 6 | |
noahdietz | 5abf802 | 2022-04-12 10:25:08 -0700 | [diff] [blame] | 7 | [The Lite version of protobuf for the JVM](https://github.com/protocolbuffers/protobuf/blob/main/java/lite.md) |
Christopher Hunt | c908fdb | 2021-02-18 11:10:42 +1100 | [diff] [blame] | 8 | avoids reflection and may be better suited for use with AOT compilation tooling. This Lite version was originally targeted for use on Android which has similar AOT compilation |
| 9 | goals as GraalVM's native-image tool. |
| 10 | |
| 11 | ## GraalVM native-image |
| 12 | |
Elliotte Rusty Harold | e41cecf | 2022-04-26 12:07:27 +0000 | [diff] [blame] | 13 | The GraalVM `native-image` tool can be configured with options for the |
| 14 | [Java Native Interface](https://www.graalvm.org/22.0/reference-manual/native-image/JNI/) (JNI), |
| 15 | http proxying, reflection, and other resources. While these |
| 16 | configuration options can be manually specified in JSON files, we recommend |
| 17 | that you exercise the application with |
Christopher Hunt | c908fdb | 2021-02-18 11:10:42 +1100 | [diff] [blame] | 18 | [the assisted configuration agent](https://www.graalvm.org/reference-manual/native-image/BuildConfiguration/#assisted-configuration-of-native-image-builds). The agent |
Elliotte Rusty Harold | e41cecf | 2022-04-26 12:07:27 +0000 | [diff] [blame] | 19 | will generate native-image.properties files that you add to the project's |
| 20 | META-INF/native-image/ directory. The Native Image builder uses configuration options provided in META-INF/native-image/ to construct native-image command line arguments. |