Contribute introspection hints on registered beans

Prior to this commit, reflection hints registered for beans was
selectively applied to only consider the methods that we'll actually
need reflection on at runtime. This would rely on an undocumented
behavior of GraalVM Native where calling `getDeclaredMethods` on a type
would only return known metadata at runtime, ignoring the ones that were
not registered during native compilation.

As of oracle/graal#5171, this behavior is now fixed in GraalVM and
aligns with the JVM behavior: all methods will be returned. This means
that if during native compilation, introspection was not registered for
the type a new `MissingReflectionMetadataException` will be raised.

As a follow up of #29205, this commit contributes the "introspection on
declared method" reflection hint for all registered beans.

Closes gh-29246
This commit is contained in:
Brian Clozel
2023-03-29 18:09:33 +02:00
parent 7e905e3e00
commit b374824319
6 changed files with 72 additions and 17 deletions

View File

@@ -18,7 +18,6 @@ package org.springframework.context.generator;
import java.util.function.BiConsumer;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
@@ -72,7 +71,6 @@ class ApplicationContextAotGeneratorRuntimeHintsTests {
}
@Test
@Disabled("until gh-29246 is re-applied")
void generateApplicationContextWithMultipleInitDestroyMethods() {
GenericApplicationContext context = new AnnotationConfigApplicationContext();
RootBeanDefinition beanDefinition = new RootBeanDefinition(InitDestroyComponent.class);