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

fix(java): add reflection configuration for native-image testing #1488

Merged
merged 1 commit into from
Jan 24, 2022

Conversation

mpeddada1
Copy link
Contributor

This PR adds reflection configuration for native-image testing. Currently running mvn test -Pnative caused ITBigQueryWriteManualClientTest to fail at the native image build step.

Caused by: java.lang.IllegalArgumentException: key v, field private java.lang.Object com.google.api.services.bigquery.model.TableCell.v
       com.google.api.client.json.JsonParser.parseValue(JsonParser.java:900)
       com.google.api.client.json.JsonParser.parse(JsonParser.java:451)
       com.google.api.client.json.JsonParser.parseValue(JsonParser.java:787)
       [...]
     Caused by: java.lang.IllegalArgumentException: unable to create new instance of class java.lang.Object because it has no accessible default constructor
       com.google.api.client.util.Types.handleExceptionForNewInstance(Types.java:162)
       com.google.api.client.util.Types.newInstance(Types.java:117)
       com.google.api.client.util.Data.createNullInstance(Data.java:166)
       com.google.api.client.util.Data.nullOf(Data.java:134)
       com.google.api.client.json.JsonParser.parseValue(JsonParser.java:883)
       [...]
     Caused by: java.lang.InstantiationException: Type `java.lang.Object` can not be instantiated reflectively as it does not have a no-parameter constructor or the no-parameter constructor has not been added explicitly to the native image.
       java.lang.Class.newInstance(DynamicHub.java:915)
       com.google.api.client.util.Types.newInstance(Types.java:113)
       [...]

During native image build, the builder performs static analysis to determine which classes are reachable from the entry-point of the application. Sometimes usages of Java reflection don't get recognized and need to be registered to let the builder know which classes to include in the binary.

@mpeddada1 mpeddada1 requested a review from a team January 24, 2022 17:57
@mpeddada1 mpeddada1 requested a review from a team as a code owner January 24, 2022 17:57
@mpeddada1 mpeddada1 requested a review from shollyman January 24, 2022 17:57
@product-auto-label product-auto-label bot added the api: bigquerystorage Issues related to the googleapis/java-bigquerystorage API. label Jan 24, 2022
@stephaniewang526 stephaniewang526 merged commit d87fe28 into main Jan 24, 2022
@stephaniewang526 stephaniewang526 deleted the fix-native branch January 24, 2022 20:31
gcf-merge-on-green bot pushed a commit that referenced this pull request Jan 25, 2022
🤖 I have created a release *beep* *boop*
---


### [2.8.2](v2.8.1...v2.8.2) (2022-01-25)


### Bug Fixes

* **java:** add reflection configuration for native-image testing ([#1488](#1488)) ([d87fe28](d87fe28))


### Documentation

* **samples:** add finalize call to our samples ([#1471](#1471)) ([47e3654](47e3654))
* **samples:** update to v1 in doc URls ([#1489](#1489)) ([7efe427](7efe427))


### Dependencies

* exclude un-used runtime dependencies brought in by gax-grpc ([#1490](#1490)) ([3e7833e](3e7833e))
* update dependency com.google.cloud:google-cloud-bigquery to v2.6.1 ([#1473](#1473)) ([f996cdb](f996cdb))
* update dependency com.google.cloud:google-cloud-bigquery to v2.6.2 ([#1475](#1475)) ([37c1fd8](37c1fd8))
* update dependency kr.motd.maven:os-maven-plugin to v1.7.0 ([#1476](#1476)) ([e038151](e038151))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.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: bigquerystorage Issues related to the googleapis/java-bigquerystorage API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants