chore: set Java header at native image runtime#2069
Merged
Conversation
meltsufin
approved these changes
May 10, 2022
| public String toString() { | ||
| // When running the application as a native image, append `-graalvm` to the | ||
| // version. | ||
| String imageCode = System.getProperty("org.graalvm.nativeimage.imagecode"); |
Member
There was a problem hiding this comment.
Please use constants instead of string literals here.
Contributor
Author
There was a problem hiding this comment.
That's a valid point! However, this might come down to the question of whether it is worth having dependency on graal-sdk in this repo? If we use the latest version (22.1.0) then we'll see the following incompatibility:
bad class file: /home/runner/.m2/repository/org/graalvm/sdk/graal-sdk/22.1.0/graal-sdk-22.1.0.jar(org/graalvm/nativeimage/ImageInfo.class)
Error: class file has wrong version 55.0, should be 52.0
Error: Please remove or make sure it appears in the correct subdirectory of the classpath.
Error: -> [Help 1]
In which case, we may need to do something similar to googleapis/gax-java#1671. This could still pose a slight risk since we still target Java 7. But open to hearing about what you think!
Member
There was a problem hiding this comment.
I'm fine with either. @suztomo what do you think? Is it worth it to bring the whole setup for compiling with 11 and testing on 7 in this case?
blakeli0
pushed a commit
that referenced
this pull request
Dec 16, 2022
* chore: set Java header during native image runtime
blakeli0
pushed a commit
that referenced
this pull request
Dec 16, 2022
* chore: set Java header during native image runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This contributes towards removing the use of the SVM dependency for native image compilation. This code makes use of the org.graalvm.nativeimage.imagecode system property instead of
Substitutionsto set the Java version at image runtime. For reference: https://www.graalvm.org/sdk/javadoc/index.html?constant-values.htmlSee reproducer: https://github.com/mpeddada1/avoid-substitutions