Skip to content

Commit

Permalink
GH-406 - Improve detection of AOT types generated by Spring.
Browse files Browse the repository at this point in the history
We now guard the annotation predicate for @generated behind a classpath check to avoid a NoClassDefFoundError on previous versions of Spring Framework.
  • Loading branch information
odrotbohm committed Jan 17, 2024
1 parent d238121 commit e7fa750
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class ApplicationModules implements Iterable<ApplicationModule> {
private static final ImportOption IMPORT_OPTION = new ImportOption.DoNotIncludeTests();
private static final boolean JGRAPHT_PRESENT = ClassUtils.isPresent("org.jgrapht.Graph",
ApplicationModules.class.getClassLoader());
private static final DescribedPredicate<CanBeAnnotated> IS_AOT_TYPE = annotatedWith(Generated.class);
private static final DescribedPredicate<CanBeAnnotated> IS_AOT_TYPE;
private static final DescribedPredicate<HasName> IS_SPRING_CGLIB_PROXY = nameContaining("$$SpringCGLIB$$");

static {
Expand All @@ -85,6 +85,14 @@ public class ApplicationModules implements Iterable<ApplicationModule> {

DETECTION_STRATEGY = loadFactories.isEmpty() ? ApplicationModuleDetectionStrategies.DIRECT_SUB_PACKAGES
: loadFactories.get(0);

IS_AOT_TYPE = ClassUtils.isPresent("org.springframework.aot.generate.Generated",
ApplicationModules.class.getClassLoader()) ? getAtGenerated() : DescribedPredicate.alwaysFalse();
}

@Nullable
private static DescribedPredicate<CanBeAnnotated> getAtGenerated() {
return annotatedWith(Generated.class);
}

private final ModulithMetadata metadata;
Expand Down

0 comments on commit e7fa750

Please sign in to comment.