Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adjust native-image config for spring-cloud-gcp #3617

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

diegomarquezp
Copy link
Contributor

Context: upgrading to GraalVM for JDK 23

Updating the image support in spring (GoogleCloudPlatform/spring-cloud-gcp#3536) caused errors at analysis time solved by GoogleCloudPlatform/spring-cloud-gcp@d3f6185

Gax seems to be a better place for this kind of configs.

Context: upgrading to GraalVM for JDK 23

Updating the image support in spring (GoogleCloudPlatform/spring-cloud-gcp#3536) caused errors at analysis time solved by GoogleCloudPlatform/spring-cloud-gcp@d3f6185

Gax seems to be a better place for this kind of configs.
@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Feb 7, 2025
@diegomarquezp
Copy link
Contributor Author

diegomarquezp commented Feb 7, 2025

The config worked in spring
image

Copy link

sonarqubecloud bot commented Feb 7, 2025

Copy link

sonarqubecloud bot commented Feb 7, 2025

Quality Gate Passed Quality Gate passed for 'java_showcase_integration_tests'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link
Contributor

@lqiu96 lqiu96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @mpeddada1 should be the final approval

@diegomarquezp
Copy link
Contributor Author

From discussion with @blakeli0, will investigate the root cause of the need for this change.

@diegomarquezp diegomarquezp merged commit c11360e into main Feb 10, 2025
51 of 52 checks passed
@diegomarquezp diegomarquezp deleted the prepare-spring-graal-23 branch February 10, 2025 19:55
Copy link
Collaborator

@blakeli0 blakeli0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is harmless so it is OK to merge it in if it is blocking GraalVM upgrade. But we need to understand why we have to make these changes and document them.

@diegomarquezp
Copy link
Contributor Author

@blakeli0 I confirmed strict-image-heap is causing the same errors in JDK 21.
See the failing jobs in GoogleCloudPlatform/spring-cloud-gcp#3544

You'll find that almost every native test fails at image build time, with some of the sub-jobs pointing exactly to the same issue fixed in this PR.

Error: An object of type 'com.google.protobuf.RuntimeVersion$RuntimeDomain' was found in the image heap. This type, however, is marked for initialization at image run time for the following reason: classes are initialized at run time by default.
This is not allowed for correctness reasons: All objects that are stored in the image heap must be initialized at build time.
------------------------------------------------------------------------------------------------------------------------

You now have two options to resolve this:

1) If it is intended that objects of type 'com.google.protobuf.RuntimeVersion$RuntimeDomain' are persisted in the image heap, add 

    '--initialize-at-build-time=com.google.protobuf.RuntimeVersion$RuntimeDomain'

Moreover, the runs in Graal JDK 21 without the strict-image-heap flag will produce a warning message telling us that we should prepare for the next release because of this new flag. See example job.

[1/8] Initializing...                                                                                    (9.8s @ 0.26GB)
 Java version: 21.0.2+13, vendor version: GraalVM CE 21.0.2+13.1
...
Recommendations:
 INIT: Adopt '--strict-image-heap' to prepare for the next GraalVM release.
 HEAP: Set max heap for improved and more predictable memory usage.
 CPU:  Enable more CPU features with '-march=native' for improved performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants