Ensure that the main application class can be deduced

Closes gh-31222
This commit is contained in:
Andy Wilkinson 2022-05-31 12:06:56 +01:00
parent 5f54289e97
commit 4385926df1
1 changed files with 6 additions and 2 deletions

View File

@ -32,6 +32,7 @@ import org.springframework.aot.generate.FileSystemGeneratedFiles;
import org.springframework.aot.generate.GeneratedFiles.Kind;
import org.springframework.aot.hint.ExecutableHint;
import org.springframework.aot.hint.ExecutableMode;
import org.springframework.aot.hint.ReflectionHints;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.TypeReference;
import org.springframework.aot.nativex.FileNativeConfigurationWriter;
@ -155,8 +156,11 @@ public class AotProcessor {
ClassName generatedInitializerClassName) {
TypeReference generatedType = TypeReference.of(generatedInitializerClassName.canonicalName());
TypeReference applicationType = TypeReference.of(this.application);
generationContext.getRuntimeHints().reflection().registerType(generatedType, (hint) -> hint
.onReachableType(applicationType).withConstructor(Collections.emptyList(), INVOKE_CONSTRUCTOR_HINT));
ReflectionHints reflection = generationContext.getRuntimeHints().reflection();
reflection.registerType(applicationType, (hint) -> {
});
reflection.registerType(generatedType, (hint) -> hint.onReachableType(applicationType)
.withConstructor(Collections.emptyList(), INVOKE_CONSTRUCTOR_HINT));
}
private Path getRoot(Kind kind) {