From 9a621df0a5e9f67c6c2b568c2d53186a7d9e8f6e Mon Sep 17 00:00:00 2001 From: Christopher Hunt Date: Sat, 13 Feb 2021 12:16:08 +1100 Subject: [PATCH 1/3] Create jvm_native_images.md Some initial text pertaining to the use of protobuf with AOT compilation tools such as the one provided by GraalVM native-image. --- docs/jvm_native_images.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 docs/jvm_native_images.md diff --git a/docs/jvm_native_images.md b/docs/jvm_native_images.md new file mode 100644 index 0000000000000..e6e440e709bb2 --- /dev/null +++ b/docs/jvm_native_images.md @@ -0,0 +1,18 @@ +# Native images for the Java Virtual Machine (JVM) + +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. +Protobuf for the JVM uses reflection and some of its target classes are not possible to determine in advance. +Historically, there were good reasons to use reflection based on APIs that were published effectively requiring them, and this situation is unlikely to change. + +[The Lite version of protobuf for the JVM](https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md) +avoids reflection and may be better suited for use with AOT compilation tooling. This Lite version was originally targetted for use on Android which has similar AOT compilation +goals as GraalVM's native-image tool. + +## GraalVM native-image + +This section addresses GraalVM's `native-image` configuration specifically as this AOT compilation tool due to its popularity. The `native-image` tool can be configured +with respect to: the [Java Native Interface](https://en.wikipedia.org/wiki/Java_Native_Interface) (JNI), http proxying, reflection, and other resources. While these +considerations can be manually declared as JSON files, we recommend that a JVM application is exercised along with +[the assisted configuration agent](https://www.graalvm.org/reference-manual/native-image/BuildConfiguration/#assisted-configuration-of-native-image-builds). The agent +will generate files that you can then subsequently point at when invoking `native-image`. We recommend that the generated files are retained with a project's source +code. From 5572d4cdc183579b76bb3c173eb320c9d8eb78f3 Mon Sep 17 00:00:00 2001 From: Christopher Hunt Date: Sat, 13 Feb 2021 12:23:30 +1100 Subject: [PATCH 2/3] Update jvm_native_images.md Fixed spelling --- docs/jvm_native_images.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/jvm_native_images.md b/docs/jvm_native_images.md index e6e440e709bb2..a0579a30ee01c 100644 --- a/docs/jvm_native_images.md +++ b/docs/jvm_native_images.md @@ -5,7 +5,7 @@ Protobuf for the JVM uses reflection and some of its target classes are not poss Historically, there were good reasons to use reflection based on APIs that were published effectively requiring them, and this situation is unlikely to change. [The Lite version of protobuf for the JVM](https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md) -avoids reflection and may be better suited for use with AOT compilation tooling. This Lite version was originally targetted for use on Android which has similar AOT compilation +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 goals as GraalVM's native-image tool. ## GraalVM native-image From 9a81c2429775ff40b443f404706e85c37ba844cc Mon Sep 17 00:00:00 2001 From: Christopher Hunt Date: Thu, 18 Feb 2021 09:23:04 +1100 Subject: [PATCH 3/3] Update and rename jvm_native_images.md to jvm_aot.md --- docs/{jvm_native_images.md => jvm_aot.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename docs/{jvm_native_images.md => jvm_aot.md} (95%) diff --git a/docs/jvm_native_images.md b/docs/jvm_aot.md similarity index 95% rename from docs/jvm_native_images.md rename to docs/jvm_aot.md index a0579a30ee01c..4eb682f54b310 100644 --- a/docs/jvm_native_images.md +++ b/docs/jvm_aot.md @@ -1,4 +1,4 @@ -# Native images for the Java Virtual Machine (JVM) +# Ahead Of Time (AOT) compilation for the Java Virtual Machine (JVM)" 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. Protobuf for the JVM uses reflection and some of its target classes are not possible to determine in advance.