aws / aws-sdk-java-v2

The official AWS SDK for Java - Version 2
Apache License 2.0
2.21k stars 853 forks source link

Optional CRC64NVME should be properly hidden in Crc64NvmeChecksum #5682

Open scrocquesel opened 1 month ago

scrocquesel commented 1 month ago

Describe the bug

When compiling in native mode with Quarkus, the build failed because Crc64NvmeChecksum class has a method exposing an optional class.

This was introduced in 2.29.0 (2.28.29 build fine).

Regression Issue

Expected Behavior

I can compile without build issue

Current Behavior

com.oracle.svm.core.util.UserError$UserException: Discovered unresolved type during parsing: software.amazon.awssdk.crt.checksums.CRC64NVME. This error is reported at image build time because class software.amazon.awssdk.checksums.internal.Crc64NvmeChecksum is registered for linking at image build time by command line and command line.
Error encountered while parsing software.amazon.awssdk.checksums.SdkChecksum.forAlgorithm(SdkChecksum.java:40) 
Parsing context:
   at software.amazon.awssdk.http.auth.aws.internal.signer.util.ChecksumUtil.fromChecksumAlgorithm(ChecksumUtil.java:55)

Reproduction Steps

  1. checkout https://github.com/quarkiverse/quarkus-amazon-services
  2. Update root pom.xml with <awssdk.version>2.29.0</awssdk.version>
  3. Compile and test native mode /mvnw -B formatter:validate verify --file pom.xml -Dnative

Possible Solution

The easiest solution would be to inline the private method getCrc64Nvme in the constructor in the Crc64NvmeChecksum.

Additional Information/Context

I tried adding a GraalVM substitution, but the target class inherits from BaseCrcChecksum, so I can’t substitute the whole class. Additionally, removing the private method isn’t feasible, as the signature requires the CRT package to be present for GraalVM to introspect the class.

AWS Java SDK version used

2.29.0

JDK version used

17

Operating System and version

linux

debora-ito commented 1 month ago

Hi @scrocquesel thank you for the report.

We'll investigate the build time error.

To anyone blocked by this: the workaround is to pin the SDK version <= 2.28.29.

debora-ito commented 3 weeks ago

@scrocquesel a fix was released via https://github.com/aws/aws-sdk-java-v2/pull/5692 in version 2.29.6.

Please test it out and let us know if you have any questions or comments.

scrocquesel commented 3 weeks ago

@scrocquesel a fix was released via #5692 in version 2.29.6.

Please test it out and let us know if you have any questions or comments.

Thank you, with the fix, I managed to provided graalvm support for Quarkus. I left a comment on the PR, if reflection to call method can be replaced with the original Function<> design. This would avoid having to explicitely add reflection metadata for native compilation.