@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2022 the original author or authors .
* Copyright 2002 - 2023 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -18,6 +18,7 @@ package org.springframework.context.generator;
@@ -18,6 +18,7 @@ package org.springframework.context.generator;
import java.util.function.BiConsumer ;
import jakarta.annotation.PreDestroy ;
import org.junit.jupiter.api.Test ;
import org.springframework.aot.hint.RuntimeHints ;
@ -80,6 +81,14 @@ class ApplicationContextAotGeneratorRuntimeHintsTests {
@@ -80,6 +81,14 @@ class ApplicationContextAotGeneratorRuntimeHintsTests {
compile ( context , ( hints , invocations ) - > assertThat ( invocations ) . match ( hints ) ) ;
}
@Test
void generateApplicationContextWithInheritedDestroyMethods ( ) {
GenericApplicationContext context = new AnnotationConfigApplicationContext ( ) ;
RootBeanDefinition beanDefinition = new RootBeanDefinition ( InheritedDestroy . class ) ;
context . registerBeanDefinition ( "initDestroyComponent" , beanDefinition ) ;
compile ( context , ( hints , invocations ) - > assertThat ( invocations ) . match ( hints ) ) ;
}
@SuppressWarnings ( { "rawtypes" , "unchecked" } )
private void compile ( GenericApplicationContext applicationContext , BiConsumer < RuntimeHints , RuntimeHintsInvocations > initializationResult ) {
ApplicationContextAotGenerator generator = new ApplicationContextAotGenerator ( ) ;
@ -98,4 +107,17 @@ class ApplicationContextAotGeneratorRuntimeHintsTests {
@@ -98,4 +107,17 @@ class ApplicationContextAotGeneratorRuntimeHintsTests {
} ) ;
}
public interface Destroyable {
@PreDestroy
default void destroy ( ) {
}
}
public static class InheritedDestroy implements Destroyable {
}
}