From f0236cfc102cf7ce06e1f733a4f40a50133d6b24 Mon Sep 17 00:00:00 2001 From: ldetmer <1771267+ldetmer@users.noreply.github.com> Date: Fri, 6 Dec 2024 20:57:37 +0000 Subject: [PATCH] fix: graalvm missing build time class when using protobuf 4.x (#3438) In case of protobuf 4+ need to include protobuf.Runtime in classes initialized at build time as that is used to determine protobuf version for graalvm. Tested, temporarily bumped protobuf dependency to 4.28.1 without including Runtime in build time class list. Received error: ``` Error: Classes that should be initialized at run time got initialized during image building: com.google.protobuf.RuntimeVersion was unintentionally initialized at build time. To see why com.google.protobuf.RuntimeVersion got initialized use --trace-class-initialization=com.google.protobuf.RuntimeVersion ``` Updated to include Runtime and received passing [native showcase tests](https://github.com/googleapis/sdk-platform-java/actions/runs/12205342463/job/34052473211?pr=3438) --- .../native-image/com.google.api/gax/native-image.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gax-java/gax/src/main/resources/META-INF/native-image/com.google.api/gax/native-image.properties b/gax-java/gax/src/main/resources/META-INF/native-image/com.google.api/gax/native-image.properties index 75b882d8a4..3ddbffe0b8 100644 --- a/gax-java/gax/src/main/resources/META-INF/native-image/com.google.api/gax/native-image.properties +++ b/gax-java/gax/src/main/resources/META-INF/native-image/com.google.api/gax/native-image.properties @@ -3,7 +3,8 @@ Args = --enable-url-protocols=https,http \ org.junit.platform.engine.TestTag,\ com.google.api.gax.core.GaxProperties,\ com.google.common.base.Platform,\ - com.google.common.base.Platform$JdkPatternCompiler \ + com.google.common.base.Platform$JdkPatternCompiler,\ + com.google.protobuf.RuntimeVersion \ --features=com.google.api.gax.nativeimage.OpenCensusFeature,\ com.google.api.gax.nativeimage.GoogleJsonClientFeature \ --add-modules=jdk.httpserver