Skip to content

Commit 8eebb5e

Browse files
committed
Polish
See gh-31575
1 parent 0ef3cb9 commit 8eebb5e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorBeanRegistrationAotProcessor.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
2323
import org.springframework.beans.factory.aot.BeanRegistrationCode;
2424
import org.springframework.beans.factory.support.RegisteredBean;
25+
import org.springframework.util.ClassUtils;
2526

2627
/**
2728
* An AOT {@link BeanRegistrationAotProcessor} that detects the presence of
@@ -30,13 +31,18 @@
3031
* @author Sebastien Deleuze
3132
* @since 6.1
3233
*/
33-
public class AspectJAdvisorBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor {
34+
class AspectJAdvisorBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor {
35+
36+
private static final boolean aspectJPresent = ClassUtils.isPresent("org.aspectj.lang.annotation.Pointcut",
37+
AspectJAdvisorBeanRegistrationAotProcessor.class.getClassLoader());
3438

3539
@Override
3640
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
37-
Class<?> beanClass = registeredBean.getBeanClass();
38-
if (AbstractAspectJAdvisorFactory.compiledByAjc(beanClass)) {
39-
return new AspectJAdvisorContribution(beanClass);
41+
if (aspectJPresent) {
42+
Class<?> beanClass = registeredBean.getBeanClass();
43+
if (AbstractAspectJAdvisorFactory.compiledByAjc(beanClass)) {
44+
return new AspectJAdvisorContribution(beanClass);
45+
}
4046
}
4147
return null;
4248
}

spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdvisorBeanRegistrationAotProcessorTests.java renamed to spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorBeanRegistrationAotProcessorTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.aop.aspectj;
17+
package org.springframework.aop.aspectj.annotation;
1818

1919
import org.junit.jupiter.api.Test;
2020

21-
import org.springframework.aop.aspectj.annotation.AspectJAdvisorBeanRegistrationAotProcessor;
2221
import org.springframework.aot.generate.GenerationContext;
2322
import org.springframework.aot.hint.MemberCategory;
2423
import org.springframework.aot.hint.RuntimeHints;
@@ -38,7 +37,7 @@
3837
*
3938
* @author Sebastien Deleuze
4039
*/
41-
public class AspectJAdvisorBeanRegistrationAotProcessorTests {
40+
class AspectJAdvisorBeanRegistrationAotProcessorTests {
4241

4342
private final GenerationContext generationContext = new TestGenerationContext();
4443

0 commit comments

Comments
 (0)