Skip to content
This repository was archived by the owner on Dec 3, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(java): register test class for reflection to fix native image test
  • Loading branch information
mpeddada1 committed Mar 16, 2022
commit 5c53259212a1e30c7958de261afb9baa5958ba10
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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);
}
Expand Down Expand Up @@ -103,4 +101,14 @@ 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");
}
}
}