From 491c94296a3cf71b8255594ebbe69510fce7d66e Mon Sep 17 00:00:00 2001 From: DF-Nico Date: Tue, 5 May 2026 14:53:46 +0200 Subject: [PATCH] chore: update depreciation in reflection hints usage Signed-off-by: DF-Nico --- .../org/springframework/shell/core/JnaRuntimeHints.java | 9 ++++----- .../springframework/shell/core/JnaRuntimeHintsTests.java | 6 +++--- .../springframework/shell/jline/JLineRuntimeHints.java | 8 +++----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/spring-shell-core/src/main/java/org/springframework/shell/core/JnaRuntimeHints.java b/spring-shell-core/src/main/java/org/springframework/shell/core/JnaRuntimeHints.java index bb28065ed..f2978cb3b 100644 --- a/spring-shell-core/src/main/java/org/springframework/shell/core/JnaRuntimeHints.java +++ b/spring-shell-core/src/main/java/org/springframework/shell/core/JnaRuntimeHints.java @@ -26,6 +26,7 @@ import org.springframework.aot.hint.ResourceHints; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; +import org.springframework.aot.hint.TypeHint; import org.springframework.aot.hint.TypeReference; /** @@ -61,11 +62,9 @@ private void registerProxies(ProxyHints proxy, String... classNames) { } private void registerForMostReflection(ReflectionHints reflection, String... classNames) { - reflection.registerTypes(typeReferences(classNames), hint -> { - hint.withMembers(MemberCategory.DECLARED_CLASSES, MemberCategory.DECLARED_FIELDS, - MemberCategory.PUBLIC_CLASSES, MemberCategory.PUBLIC_FIELDS, - MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS); - }); + reflection.registerTypes(typeReferences(classNames), + TypeHint.builtWith(MemberCategory.ACCESS_DECLARED_FIELDS, MemberCategory.ACCESS_PUBLIC_FIELDS, + MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS)); } private List typeReferences(String... classNames) { diff --git a/spring-shell-core/src/test/java/org/springframework/shell/core/JnaRuntimeHintsTests.java b/spring-shell-core/src/test/java/org/springframework/shell/core/JnaRuntimeHintsTests.java index 9d77ddc68..63c25de6e 100644 --- a/spring-shell-core/src/test/java/org/springframework/shell/core/JnaRuntimeHintsTests.java +++ b/spring-shell-core/src/test/java/org/springframework/shell/core/JnaRuntimeHintsTests.java @@ -44,9 +44,9 @@ void test() { TypeHint typeHint = hints.getTypeHint(typeReference); assertThat(typeHint).withFailMessage(() -> "No hints found for typeReference " + typeReference).isNotNull(); Set memberCategories = typeHint.getMemberCategories(); - assertThat(memberCategories).containsExactlyInAnyOrder(MemberCategory.DECLARED_CLASSES, - MemberCategory.DECLARED_FIELDS, MemberCategory.PUBLIC_CLASSES, MemberCategory.PUBLIC_FIELDS, - MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS); + assertThat(memberCategories).containsExactlyInAnyOrder(MemberCategory.ACCESS_DECLARED_FIELDS, + MemberCategory.ACCESS_PUBLIC_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, + MemberCategory.INVOKE_PUBLIC_METHODS); }); } diff --git a/spring-shell-jline/src/main/java/org/springframework/shell/jline/JLineRuntimeHints.java b/spring-shell-jline/src/main/java/org/springframework/shell/jline/JLineRuntimeHints.java index 94403337d..65d1458e2 100644 --- a/spring-shell-jline/src/main/java/org/springframework/shell/jline/JLineRuntimeHints.java +++ b/spring-shell-jline/src/main/java/org/springframework/shell/jline/JLineRuntimeHints.java @@ -67,11 +67,9 @@ private List typeReferences(String... classNames) { } private void registerForMostReflection(ReflectionHints reflection, String... classNames) { - reflection.registerTypes(typeReferences(classNames), hint -> { - hint.withMembers(MemberCategory.DECLARED_CLASSES, MemberCategory.DECLARED_FIELDS, - MemberCategory.PUBLIC_CLASSES, MemberCategory.PUBLIC_FIELDS, - MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS); - }); + reflection.registerTypes(typeReferences(classNames), + TypeHint.builtWith(MemberCategory.ACCESS_DECLARED_FIELDS, MemberCategory.ACCESS_PUBLIC_FIELDS, + MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS)); } private void registerJni(ReflectionHints jni) {