gapic-generator-java
gapic-generator-java copied to clipboard
Some downstream native configs initialize JUnit classes at build time in production
From https://github.com/googleapis/sdk-platform-java/pull/3674
Some libraries mark JUnit classes for initialization at build time in its production native properties file.
For example: https://github.com/googleapis/java-spanner-jdbc/blob/fa65ead20018c083749bb1bd1cc1993f48745ef9/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-spanner-jdbc/native-image.properties#L15
I tried moving it to a test-only config file (src/test/resources...) but the image creation would fail asking to specify the JUnit classes to be initialized at runtime.
I tried moving it to a test-only config file (src/test/resources...) but the image creation would fail
What exactly does this mean? @diegomarquezp Can you please provide more info regarding how to reproduce it?
I tried moving it to a test-only config file (src/test/resources...) but the image creation would fail
What exactly does this mean? [@diegomarquezp
](https://github.com/diegomarquezp) Can you please provide more info regarding how to reproduce it?
@blakeli0 This is pretty much what was attempted in https://github.com/googleapis/java-spanner-jdbc/pull/1908/commits/d78fe2f5ff06c0675054deaf95fb9b709fae796f. When it comes to "the image creation would fail" I was thinking of the failing GraalVM checks in that commit.
The attempt was: Since some JUnit classes are found in src/main/resources/.../native-image.properties, I thought it would be more appropiate to move them to src/test/resources/.../native-image.properties, but the GraalVM image creation would fail complaining with the following error as if the test folder's properties file wasn't being considered:
Fatal error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: An object of type 'org.junit.runners.Parameterized' was found in the image heap. This type, however, is marked for initialization at image run time for the following reason: classes are initialized at run time by default.
This is not allowed for correctness reasons: All objects that are stored in the image heap must be initialized at build time.
You now have two options to resolve this:
1) If it is intended that objects of type 'org.junit.runners.Parameterized' are persisted in the image heap, add
'--initialize-at-build-time=org.junit.runners.Parameterized'