|
21 | 21 | import com.oracle.svm.core.configure.ResourcesRegistry;
|
22 | 22 | import org.graalvm.nativeimage.ImageSingletons;
|
23 | 23 | import org.graalvm.nativeimage.hosted.Feature;
|
| 24 | +import org.graalvm.nativeimage.impl.ConfigurationCondition; |
24 | 25 |
|
25 | 26 | /** Registers Spanner library classes for reflection. */
|
26 | 27 | @AutomaticFeature
|
27 | 28 | final class SpannerFeature implements Feature {
|
28 | 29 |
|
29 | 30 | private static final String SPANNER_CLASS = "com.google.spanner.v1.SpannerGrpc";
|
30 | 31 | 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"; |
31 | 50 |
|
32 | 51 | @Override
|
33 | 52 | public void beforeAnalysis(BeforeAnalysisAccess access) {
|
34 | 53 | Class<?> spannerTestClass = access.findClassByName(SPANNER_TEST_CLASS);
|
35 | 54 | if (spannerTestClass != null) {
|
36 | 55 | NativeImageUtils.registerConstructorsForReflection(access, SPANNER_TEST_CLASS);
|
37 | 56 | }
|
| 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 | + |
38 | 85 | Class<?> spannerClass = access.findClassByName(SPANNER_CLASS);
|
39 | 86 | if (spannerClass != null) {
|
40 | 87 | NativeImageUtils.registerClassHierarchyForReflection(
|
@@ -47,9 +94,13 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
|
47 | 94 | // Resources
|
48 | 95 | ResourcesRegistry resourcesRegistry = ImageSingletons.lookup(ResourcesRegistry.class);
|
49 | 96 | resourcesRegistry.addResources(
|
| 97 | +ConfigurationCondition.alwaysTrue(), |
50 | 98 | "\\Qcom/google/cloud/spanner/connection/ClientSideStatements.json\\E");
|
51 | 99 | resourcesRegistry.addResources(
|
52 | 100 | "\\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"); |
53 | 104 | }
|
54 | 105 | }
|
55 | 106 | }
|
0 commit comments