Skip to content

fix(java): initialize classes at build-time to address native image 22.2.0 issues#1026

Merged
blakeli0 merged 3 commits intomainfrom
22.2.0-fixes
Oct 26, 2022
Merged

fix(java): initialize classes at build-time to address native image 22.2.0 issues#1026
blakeli0 merged 3 commits intomainfrom
22.2.0-fixes

Conversation

@mpeddada1
Copy link
Contributor

@mpeddada1 mpeddada1 commented Oct 26, 2022

Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of com.google.cloud.spanner.Dialect$1 are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use --trace-object-instantiation=com.google.cloud.spanner.Dialect$1.
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.checkImageHeapInstance(ClassInitializationFeature.java:140)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisUniverse.replaceObject(AnalysisUniverse.java:583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.replaceObject(AnalysisConstantReflectionProvider.java:257)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.interceptValue(AnalysisConstantReflectionProvider.java:228)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.heap.SVMImageHeapScanner.transformFieldValue(SVMImageHeapScanner.java:126)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.onFieldValueReachable(ImageHeapScanner.java:331)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$createImageHeapObject$3(ImageHeapScanner.java:272)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        ... 10 more
Fatal error: org.graalvm.compiler.debug.GraalError: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of com.google.cloud.spanner.Dialect$2 are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use --trace-object-instantiation=com.google.cloud.spanner.Dialect$2.

In GraalVM 22.2.0, com.google.cloud.spanner.Dialect gets initialized at build-time, causing com.google.spanner.admin.database.v1.DatabaseDialect to also be initialized at build time.

@mpeddada1 mpeddada1 requested review from a team October 26, 2022 18:32
@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. api: spanner Issues related to the googleapis/java-spanner-jdbc API. labels Oct 26, 2022
@mpeddada1 mpeddada1 added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 26, 2022
@mpeddada1 mpeddada1 removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 26, 2022
@blakeli0 blakeli0 merged commit 8010da5 into main Oct 26, 2022
@blakeli0 blakeli0 deleted the 22.2.0-fixes branch October 26, 2022 21:25
gcf-merge-on-green bot pushed a commit that referenced this pull request Oct 27, 2022
🤖 I have created a release *beep* *boop*
---


## [2.7.12](https://togithub.com/googleapis/java-spanner-jdbc/compare/v2.7.11...v2.7.12) (2022-10-27)


### Bug Fixes

* **java:** Initialize classes at build-time to address native image 22.2.0 issues ([#1026](https://togithub.com/googleapis/java-spanner-jdbc/issues/1026)) ([8010da5](https://togithub.com/googleapis/java-spanner-jdbc/commit/8010da5ef539d509eb7f96d9b89edf35b2e809ad))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner-jdbc API. size: xs Pull request size is extra small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants