From 8b9f95d63b336b0cb5c9ce2610c736cb5e2472f3 Mon Sep 17 00:00:00 2001 From: Olga MaciaszekSharma Date: Tue, 5 Dec 2023 14:32:44 +0100 Subject: [PATCH] Restructure hints. --- .../config/ConfigServerRuntimeHints.java | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/config/ConfigServerRuntimeHints.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/config/ConfigServerRuntimeHints.java index 2cd44ab5..90173142 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/config/ConfigServerRuntimeHints.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/config/ConfigServerRuntimeHints.java @@ -69,31 +69,34 @@ class ConfigServerRuntimeHints implements RuntimeHintsRegistrar { TypeReference.of(PropertyValueDescriptor.class)), hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)); hints.reflection().registerTypes( - Set.of(TypeReference.of(PropertyValueDescriptor.class), TypeReference.of(Mac.class), - TypeReference.of(KeyAgreement.class), TypeReference.of(KeyPairGenerator.class), - TypeReference.of(KeyFactory.class), TypeReference.of(Signature.class), - TypeReference.of(MessageDigest.class)), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS)); + Set.of(TypeReference.of(PropertyValueDescriptor.class), TypeReference.of(Mac.class), + TypeReference.of(KeyAgreement.class), TypeReference.of(KeyPairGenerator.class), + TypeReference.of(KeyFactory.class), TypeReference.of(Signature.class), + TypeReference.of(MessageDigest.class)), + hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS)); + + // TODO: move over to GraalVM reachability metadata if (ClassUtils.isPresent("org.apache.sshd.common.SshConstants", classLoader)) { - hints.reflection() - .registerTypes(Set.of(TypeReference.of(BouncyCastleSecurityProviderRegistrar.class), - TypeReference.of(EdDSASecurityProviderRegistrar.class), TypeReference.of(SshdText.class), - TypeReference.of(Nio2ServiceFactory.class), TypeReference.of(Nio2ServiceFactoryFactory.class)), + hints.reflection().registerTypes(Set.of(TypeReference.of(BouncyCastleSecurityProviderRegistrar.class), + TypeReference.of(EdDSASecurityProviderRegistrar.class), TypeReference.of(Nio2ServiceFactory.class), + TypeReference.of(Nio2ServiceFactoryFactory.class)), hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)); - hints.reflection() - .registerTypes(Set.of(TypeReference.of(MergeCommand.FastForwardMode.Merge.class), - TypeReference.of(MergeCommand.ConflictStyle.class), - TypeReference.of(MergeCommand.FastForwardMode.class), TypeReference.of(FetchCommand.class)), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS)); - hints.reflection() - .registerTypes(Set.of(TypeReference.of(PortForwardingEventListener.class)), + hints.reflection().registerTypes(Set.of(TypeReference.of(PortForwardingEventListener.class)), hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, - MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS)); - hints.reflection() - .registerTypes(Set.of(TypeReference.of(SshdText.class)), hint -> hint - .withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS)); + MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS)); hints.proxies().registerJdkProxy(TypeReference.of(ChannelListener.class), - TypeReference.of(PortForwardingEventListener.class), TypeReference.of(SessionListener.class)); + TypeReference.of(PortForwardingEventListener.class), TypeReference.of(SessionListener.class)); + } + + // TODO: move over to GraalVM reachability metadata + if (ClassUtils.isPresent("org.eclipse.jgit.api.Git", classLoader)) { + hints.reflection() + .registerTypes(Set.of(TypeReference.of(MergeCommand.FastForwardMode.Merge.class), + TypeReference.of(MergeCommand.ConflictStyle.class), + TypeReference.of(MergeCommand.FastForwardMode.class), TypeReference.of(FetchCommand.class)), + hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS)); + hints.reflection().registerTypes(Set.of(TypeReference.of(SshdText.class)), hint -> hint + .withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS)); } }