diff --git a/java-core/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/SpannerFeature.java b/java-core/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/SpannerFeature.java index 7c9fca142163..956f368dacf6 100644 --- a/java-core/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/SpannerFeature.java +++ b/java-core/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/SpannerFeature.java @@ -29,6 +29,7 @@ final class SpannerFeature implements Feature { private static final String SPANNER_CLASS = "com.google.spanner.v1.SpannerGrpc"; private static final String SPANNER_TEST_CLASS = "com.google.cloud.spanner.GceTestEnvConfig"; + private static final String MOCK_CLASS = "com.google.cloud.spanner.MockDatabaseAdminServiceImpl"; private static final String CLIENT_SIDE_IMPL_CLASS = "com.google.cloud.spanner.connection.ClientSideStatementImpl"; private static final String CLIENT_SIDE_VALUE_CONVERTER = @@ -50,10 +51,7 @@ final class SpannerFeature implements Feature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { - Class spannerTestClass = access.findClassByName(SPANNER_TEST_CLASS); - if (spannerTestClass != null) { - NativeImageUtils.registerConstructorsForReflection(access, SPANNER_TEST_CLASS); - } + registerSpannerTestClasses(access); if (access.findClassByName(CLIENT_SIDE_IMPL_CLASS) != null) { NativeImageUtils.registerClassHierarchyForReflection(access, CLIENT_SIDE_IMPL_CLASS); } @@ -103,4 +101,16 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { "\\Qcom/google/cloud/spanner/connection/ITSqlScriptTest_TestQueryOptions.sql\\E"); } } + + private void registerSpannerTestClasses(BeforeAnalysisAccess access) { + Class spannerTestClass = access.findClassByName(SPANNER_TEST_CLASS); + if (spannerTestClass != null) { + NativeImageUtils.registerConstructorsForReflection(access, SPANNER_TEST_CLASS); + } + Class mockClass = access.findClassByName(MOCK_CLASS); + if (mockClass != null) { + NativeImageUtils.registerClassForReflection( + access, "com.google.cloud.spanner.MockDatabaseAdminServiceImpl$MockBackup"); + } + } }