Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

fix(java): initialize spanner test environment class at build-time and add reflection configurations #734

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
@AutomaticFeature
final class OpenCensusFeature implements Feature {

private static final String OPEN_CENSUS_CLASS = "io.opencensus.impl.tags.TagsComponentImpl";
private static final String TAGS_COMPONENT_CLASS = "io.opencensus.impl.tags.TagsComponentImpl";
private static final String STATS_COMPONENT_CLASS = "io.opencensus.impl.stats.StatsComponentImpl";

@Override
public void beforeAnalysis(BeforeAnalysisAccess access) {
if (access.findClassByName(OPEN_CENSUS_CLASS) != null) {
if (access.findClassByName(STATS_COMPONENT_CLASS) != null) {
registerForReflectiveInstantiation(access, STATS_COMPONENT_CLASS);
}
if (access.findClassByName(TAGS_COMPONENT_CLASS) != null) {
registerForReflectiveInstantiation(access, "io.opencensus.impl.metrics.MetricsComponentImpl");
registerForReflectiveInstantiation(access, "io.opencensus.impl.tags.TagsComponentImpl");
registerForReflectiveInstantiation(access, "io.opencensus.impl.trace.TraceComponentImpl");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@
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";

@Override
public void beforeAnalysis(BeforeAnalysisAccess access) {
Class<?> spannerTestClass = access.findClassByName(SPANNER_TEST_CLASS);
if (spannerTestClass != null) {
NativeImageUtils.registerConstructorsForReflection(access, SPANNER_TEST_CLASS);
}
Class<?> spannerClass = access.findClassByName(SPANNER_CLASS);
if (spannerClass != null) {
NativeImageUtils.registerClassHierarchyForReflection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Args = --allow-incomplete-classpath \
--enable-url-protocols=https,http \
--initialize-at-build-time=org.conscrypt,\
org.slf4j.LoggerFactory,\
org.junit.platform.engine.TestTag \
org.junit.platform.engine.TestTag,\
com.google.cloud.spanner.IntegrationTestEnv \
--initialize-at-run-time=io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl,\
io.grpc.netty.shaded.io.netty.internal.tcnative.SSL,\
io.grpc.netty.shaded.io.netty.internal.tcnative.CertificateVerifier,\
Expand Down