Native image build fails due to CachedSupplier/SplittableRandom
See original GitHub issueDescribe the bug
Building a native image with Graal fails with the latest AWS SDK 2.17.238 The issue did not yet exist with AWS SDK 2.16.51.
I was able to work around it by using --initialize-at-run-time=software.amazon.awssdk.utils.cache.CachedSupplier
.
Expected Behavior
No error
Current Behavior
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace:
at parsing software.amazon.awssdk.utils.cache.CachedSupplier.jitterTime(CachedSupplier.java:326)
Reproduction Steps
Can be reproduced with Graal 21.3.0 and ‘GraalVM 22.1.0.0-Final Java 17 Mandrel Distribution’.
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.17.238
JDK version used
11 and 17
Operating System and version
Linux
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Working with Random/SplittableRandom instances in ...
Embedding them in a native image results in the seed value that was generated at build-time to be cached in the native image,...
Read more >Quarkus Native Image Build Failure - java - Stack Overflow
This means that if you use Random/SplittableRandom in your code this will be initialized at build time and thus this error.
Read more >Tips for writing native applications - Quarkus
Instances created during image generation have cached seed values and don't behave as expected. Which is more often than not caused by Quarkus...
Read more >Fix GraalVM Native Image Build Issues - Simply-How.com
1. Introduction 2. Getting started 3. Build-time errors
Read more >New Feature - Release Notes - Java Bug System
createDirectories to get MaxPathLength.java failure details ... [JDK-7089914] - Focus on image icons are not visible in javaws cache with high contrast mode ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks! Yes, I also have the same problem, my relateddependencies are:
Hi. Okay interesting. Maybe an important aspect is that I’m using the url-connection-client (because I’m using the AWS SDK with Quarkus). I’m including the SDK like this in my Gradle build.gradle.kt file:
Hope that helps to reproduce. At least one other person also got the same issue as reported here https://github.com/quarkusio/quarkus/issues/14904#issuecomment-1057799863