Native GraalVM compilation fail when reading environment variables with System.getenv(" ")

113 Views Asked by At

The below code is giving error when trying to compilate to native image, using Quarkus native image build.

val temporalServerAddress: String = System.getenv("TEMPORAL_SERVER") ?: "127.0.0.1:7233"
val service = WorkflowServiceStubs.newServiceStubs(
    WorkflowServiceStubsOptions.newBuilder().setTarget(temporalServerAddress).build()
)

Error

Java version: 20.0.2+9, vendor version: GraalVM CE 20.0.2+9.1 Graal compiler: optimization level: 2, target machine: armv8-a C compiler: cc (apple, arm64, 14.0.3) Garbage collector: Serial GC (max heap size: 80% of RAM) 3 user-specific feature(s)

  • com.oracle.svm.thirdparty.gson.GsonFeature
  • io.quarkus.runner.Feature: Auto-generated class by Quarkus from the existing extensions
  • io.quarkus.runtime.graal.DisableLoggingFeature: Disables INFO logging during the analysis phase Warning: RecomputeFieldValue.FieldOffset automatic substitution failed. The automatic substitution registration was attempted because a call to sun.misc.Unsafe.objectFieldOffset(Field) was detected in the static initializer of com.google.protobuf.UnsafeUtil. Detailed failure reason(s): The argument of sun.misc.Unsafe.objectFieldOffset(java.lang.reflect.Field) is not a constant value or a field load that can be constant-folded., Could not determine the field where the value produced by the call to sun.misc.Unsafe.objectFieldOffset(Field) for the field offset computation is stored. The call is not directly followed by a field store or by a sign extend node followed directly by a field store. [2/8] Performing analysis... []
    (9.0s @ 1.16GB) 7,709 (78.54%) of 9,816 types reachable 10,011 (47.18%) of 21,217 fields reachable 35,513 (37.18%) of 95,505 methods reachable 2,616 types, 101 fields, and 1,788 methods registered for reflection 1 native library: -framework CoreServices

Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing io.grpc.netty.shaded.io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator.(JdkNpnApplicationProtocolNegotiator.java:27) Parsing context: at static root method.(Unknown Source)

    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:149)
0

There are 0 best solutions below