See gh-31575
This commit is contained in:
Brian Clozel
2023-11-15 15:26:49 +01:00
parent 0ef3cb9b9e
commit 8eebb5e27b
2 changed files with 12 additions and 7 deletions

View File

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
import org.springframework.beans.factory.aot.BeanRegistrationCode;
import org.springframework.beans.factory.support.RegisteredBean;
import org.springframework.util.ClassUtils;
/**
* An AOT {@link BeanRegistrationAotProcessor} that detects the presence of
@@ -30,13 +31,18 @@ import org.springframework.beans.factory.support.RegisteredBean;
* @author Sebastien Deleuze
* @since 6.1
*/
public class AspectJAdvisorBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor {
class AspectJAdvisorBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor {
private static final boolean aspectJPresent = ClassUtils.isPresent("org.aspectj.lang.annotation.Pointcut",
AspectJAdvisorBeanRegistrationAotProcessor.class.getClassLoader());
@Override
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
Class<?> beanClass = registeredBean.getBeanClass();
if (AbstractAspectJAdvisorFactory.compiledByAjc(beanClass)) {
return new AspectJAdvisorContribution(beanClass);
if (aspectJPresent) {
Class<?> beanClass = registeredBean.getBeanClass();
if (AbstractAspectJAdvisorFactory.compiledByAjc(beanClass)) {
return new AspectJAdvisorContribution(beanClass);
}
}
return null;
}

View File

@@ -14,11 +14,10 @@
* limitations under the License.
*/
package org.springframework.aop.aspectj;
package org.springframework.aop.aspectj.annotation;
import org.junit.jupiter.api.Test;
import org.springframework.aop.aspectj.annotation.AspectJAdvisorBeanRegistrationAotProcessor;
import org.springframework.aot.generate.GenerationContext;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
@@ -38,7 +37,7 @@ import static org.springframework.aot.hint.predicate.RuntimeHintsPredicates.refl
*
* @author Sebastien Deleuze
*/
public class AspectJAdvisorBeanRegistrationAotProcessorTests {
class AspectJAdvisorBeanRegistrationAotProcessorTests {
private final GenerationContext generationContext = new TestGenerationContext();