2121import com .oracle .svm .core .configure .ResourcesRegistry ;
2222import org .graalvm .nativeimage .ImageSingletons ;
2323import org .graalvm .nativeimage .hosted .Feature ;
24+ import org .graalvm .nativeimage .impl .ConfigurationCondition ;
2425
2526/** Registers Spanner library classes for reflection. */
2627@ AutomaticFeature
2728final class SpannerFeature implements Feature {
2829
2930 private static final String SPANNER_CLASS = "com.google.spanner.v1.SpannerGrpc" ;
3031 private static final String SPANNER_TEST_CLASS = "com.google.cloud.spanner.GceTestEnvConfig" ;
32+ private static final String CLIENT_SIDE_IMPL_CLASS =
33+ "com.google.cloud.spanner.connection.ClientSideStatementImpl" ;
34+ private static final String CLIENT_SIDE_VALUE_CONVERTER =
35+ "com.google.cloud.spanner.connection.ClientSideStatementValueConverters" ;
36+ private static final String CONNECTION_IMPL =
37+ "com.google.cloud.spanner.connection.ConnectionImpl" ;
38+ private static final String CLIENT_SIDE_STATEMENTS =
39+ "com.google.cloud.spanner.connection.ClientSideStatements" ;
40+ private static final String CONNECTION_STATEMENT_EXECUTOR =
41+ "com.google.cloud.spanner.connection.ConnectionStatementExecutor" ;
42+ private static final String CLIENT_SIDE_STATEMENT_NO_PARAM_EXECUTOR =
43+ "com.google.cloud.spanner.connection.ClientSideStatementNoParamExecutor" ;
44+ private static final String CLIENT_SIDE_STATEMENT_SET_EXECUTOR =
45+ "com.google.cloud.spanner.connection.ClientSideStatementSetExecutor" ;
46+ private static final String ABSTRACT_STATEMENT_PARSER =
47+ "com.google.cloud.spanner.connection.AbstractStatementParser" ;
48+ private static final String STATEMENT_PARSER =
49+ "com.google.cloud.spanner.connection.SpannerStatementParser" ;
3150
3251 @ Override
3352 public void beforeAnalysis (BeforeAnalysisAccess access ) {
3453 Class <?> spannerTestClass = access .findClassByName (SPANNER_TEST_CLASS );
3554 if (spannerTestClass != null ) {
3655 NativeImageUtils .registerConstructorsForReflection (access , SPANNER_TEST_CLASS );
3756 }
57+ if (access .findClassByName (CLIENT_SIDE_IMPL_CLASS ) != null ) {
58+ NativeImageUtils .registerClassHierarchyForReflection (access , CLIENT_SIDE_IMPL_CLASS );
59+ }
60+ if (access .findClassByName (CLIENT_SIDE_STATEMENT_NO_PARAM_EXECUTOR ) != null ) {
61+ NativeImageUtils .registerClassForReflection (access , CLIENT_SIDE_STATEMENT_NO_PARAM_EXECUTOR );
62+ }
63+ if (access .findClassByName (CLIENT_SIDE_STATEMENT_SET_EXECUTOR ) != null ) {
64+ NativeImageUtils .registerClassForReflection (access , CLIENT_SIDE_STATEMENT_SET_EXECUTOR );
65+ }
66+ if (access .findClassByName (CLIENT_SIDE_VALUE_CONVERTER ) != null ) {
67+ NativeImageUtils .registerClassHierarchyForReflection (access , CLIENT_SIDE_VALUE_CONVERTER );
68+ }
69+ if (access .findClassByName (CLIENT_SIDE_STATEMENTS ) != null ) {
70+ NativeImageUtils .registerClassForReflection (access , CLIENT_SIDE_STATEMENTS );
71+ }
72+ if (access .findClassByName (CONNECTION_STATEMENT_EXECUTOR ) != null ) {
73+ NativeImageUtils .registerClassForReflection (access , CONNECTION_STATEMENT_EXECUTOR );
74+ }
75+ if (access .findClassByName (CONNECTION_IMPL ) != null ) {
76+ NativeImageUtils .registerClassForReflection (access , CONNECTION_IMPL );
77+ }
78+ if (access .findClassByName (ABSTRACT_STATEMENT_PARSER ) != null ) {
79+ NativeImageUtils .registerClassHierarchyForReflection (access , ABSTRACT_STATEMENT_PARSER );
80+ }
81+ if (access .findClassByName (STATEMENT_PARSER ) != null ) {
82+ NativeImageUtils .registerConstructorsForReflection (access , STATEMENT_PARSER );
83+ }
84+
3885 Class <?> spannerClass = access .findClassByName (SPANNER_CLASS );
3986 if (spannerClass != null ) {
4087 NativeImageUtils .registerClassHierarchyForReflection (
@@ -47,9 +94,13 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
4794 // Resources
4895 ResourcesRegistry resourcesRegistry = ImageSingletons .lookup (ResourcesRegistry .class );
4996 resourcesRegistry .addResources (
97+ ConfigurationCondition .alwaysTrue (),
5098 "\\ Qcom/google/cloud/spanner/connection/ClientSideStatements.json\\ E" );
5199 resourcesRegistry .addResources (
52100 "\\ Qcom/google/cloud/spanner/spi/v1/grpc-gcp-apiconfig.json\\ E" );
101+ resourcesRegistry .addResources (
102+ ConfigurationCondition .alwaysTrue (),
103+ "\\ Qcom/google/cloud/spanner/connection/ITSqlScriptTest_TestQueryOptions.sql\\ E" );
53104 }
54105 }
55106}
0 commit comments