Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

feat(java): Add native-image support classes to java-core module #637

Merged
merged 9 commits into from
Jan 18, 2022

Conversation

dzou
Copy link
Contributor

@dzou dzou commented Nov 29, 2021

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.

@dzou dzou requested a review from a team as a code owner November 29, 2021 23:59
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 29, 2021
@@ -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>
Copy link
Member

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?

Copy link
Contributor Author

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.

<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} -->
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@dzou dzou added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 12, 2022
@dzou dzou requested a review from mpeddada1 January 12, 2022 16:26
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 12, 2022
@dzou
Copy link
Contributor Author

dzou commented Jan 12, 2022

@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 {
Copy link
Contributor

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.

Copy link
Member

@meltsufin meltsufin left a 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 \
Copy link
Contributor

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?

Copy link
Contributor

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.

@mpeddada1 mpeddada1 merged commit 154bc18 into main Jan 18, 2022
@mpeddada1 mpeddada1 deleted the add-native-support branch January 18, 2022 16:45
@mpeddada1
Copy link
Contributor

Thanks for the reviews @lesv, @meltsufin and @suztomo!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants