-
Notifications
You must be signed in to change notification settings - Fork 39
feat(java): Add native-image support classes to java-core module #637
Conversation
google-cloud-core-bom/pom.xml
Outdated
@@ -75,6 +75,11 @@ | |||
<artifactId>google-cloud-core-http</artifactId> | |||
<version>2.3.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-core:current} --> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.google.cloud</groupId> | |||
<artifactId>google-cloud-core-native-support</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you clarify the reasons for this artifact renaming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm good point. I originally wanted to fit into naming conventions in this repo. But I think there will be convenience benefits for keeping artifact IDs the same. So I renamed it back to native-image-support
.
google-cloud-core-bom/pom.xml
Outdated
<dependency> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>google-cloud-core-native-support</artifactId> | ||
<version>2.3.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-core:current} --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would mark the native support as GA (post 1.0). We should define a version that matches the artifact status.
Yoshi automation tool has capability to define different versions in a repository. For example gax-httpjson is pre 1.0 but gax is 2.7.0.
https://github.com/googleapis/gax-java/blob/main/gax-httpjson/build.gradle#L4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
# Conflicts: # pom.xml # versions.txt
@mpeddada1 - Hey, please take a look at this PR when you get a chance. It simply migrates the native-image-support project here. I've kept the group ID, artifact ID the same so that migration for users should me much easier. |
* <p>To add this feature, add "--feature | ||
* com.google.cloud.nativeimage.features.ProtobufMessageFeature" to your GraalVM configuration. | ||
*/ | ||
final class ProtobufMessageFeature implements Feature { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider adding the AutomaticFeature
annotation here? Since this feature is needed for a couple of libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check with @lesv in regards to what to do with the old repo, specifically the samples.
@@ -0,0 +1,14 @@ | |||
Args = --allow-incomplete-classpath \ | |||
--enable-url-protocols=https,http \ | |||
--initialize-at-build-time=org.conscrypt \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's calling this in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These arguments are used for the native-image
compiler which is used to build the native image. It includes all common the settings that are required for native image compilation to work.
For example:
As part of some optimizations, Native Image tends to initialize certain classes at build-time (when the native image is being built). However, some classes/values cannot be initialized at build-time, which results in errors that look like this: Classes that should be initialized at run time got initialized during image building
so we need to specify which ones need to be initialized at run-time. The initialize-at-build-time
and -initialize-at-run-time
args are used for this purpose.
Thanks for the reviews @lesv, @meltsufin and @suztomo! |
Introduces native-image support in a new module
native-image-support
.Currently this does not make
google-cloud-core
add it as a dependency just yet. Planning on adding downstream testing first before making it a dependency.