Add the necessary hints for use of Cglib proxies
This commit expands GeneratedClassHandler to allow invocation of declared fields and methods. Generated proxies have a number of internal fields and methods that are invoked via reflection. See gh-28954
This commit is contained in:
@@ -39,7 +39,9 @@ import org.springframework.core.io.ByteArrayResource;
|
||||
class GeneratedClassHandler implements BiConsumer<String, byte[]> {
|
||||
|
||||
private static final Consumer<Builder> asCglibProxy = hint ->
|
||||
hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_DECLARED_METHODS,
|
||||
MemberCategory.DECLARED_FIELDS);
|
||||
|
||||
private final RuntimeHints runtimeHints;
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ class GeneratedClassHandlerTests {
|
||||
String className = "com.example.Test$$Proxy$$1";
|
||||
this.handler.accept(className, TEST_CONTENT);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(TypeReference.of(className))
|
||||
.withMemberCategory(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS))
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(this.generationContext.getRuntimeHints());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user