@@ -531,16 +531,14 @@ private void collectImports(SourceClass sourceClass, Set<SourceClass> imports, S
531
531
if (visited .add (sourceClass )) {
532
532
for (SourceClass annotation : sourceClass .getAnnotations ()) {
533
533
String annName = annotation .getMetadata ().getClassName ();
534
- if (!annName .startsWith ( "java" ) && ! annName . equals (Import .class .getName ())) {
534
+ if (!annName .equals (Import .class .getName ())) {
535
535
collectImports (annotation , imports , visited );
536
536
}
537
537
}
538
538
imports .addAll (sourceClass .getAnnotationAttributes (Import .class .getName (), "value" ));
539
539
}
540
540
}
541
541
542
-
543
-
544
542
private void processImports (ConfigurationClass configClass , SourceClass currentSourceClass ,
545
543
Collection <SourceClass > importCandidates , boolean checkForCircularImports ) {
546
544
@@ -562,8 +560,7 @@ private void processImports(ConfigurationClass configClass, SourceClass currentS
562
560
ParserStrategyUtils .invokeAwareMethods (
563
561
selector , this .environment , this .resourceLoader , this .registry );
564
562
if (selector instanceof DeferredImportSelector ) {
565
- this .deferredImportSelectorHandler .handle (
566
- configClass , (DeferredImportSelector ) selector );
563
+ this .deferredImportSelectorHandler .handle (configClass , (DeferredImportSelector ) selector );
567
564
}
568
565
else {
569
566
String [] importClassNames = selector .selectImports (currentSourceClass .getMetadata ());
@@ -1016,13 +1013,32 @@ public Set<SourceClass> getInterfaces() throws IOException {
1016
1013
1017
1014
public Set <SourceClass > getAnnotations () {
1018
1015
Set <SourceClass > result = new LinkedHashSet <>();
1019
- for (String className : this .metadata .getAnnotationTypes ()) {
1020
- try {
1021
- result .add (getRelated (className ));
1016
+ if (this .source instanceof Class ) {
1017
+ Class <?> sourceClass = (Class <?>) this .source ;
1018
+ for (Annotation ann : sourceClass .getAnnotations ()) {
1019
+ Class <?> annType = ann .annotationType ();
1020
+ if (!annType .getName ().startsWith ("java" )) {
1021
+ try {
1022
+ result .add (asSourceClass (annType ));
1023
+ }
1024
+ catch (Throwable ex ) {
1025
+ // An annotation not present on the classpath is being ignored
1026
+ // by the JVM's class loading -> ignore here as well.
1027
+ }
1028
+ }
1022
1029
}
1023
- catch (Throwable ex ) {
1024
- // An annotation not present on the classpath is being ignored
1025
- // by the JVM's class loading -> ignore here as well.
1030
+ }
1031
+ else {
1032
+ for (String className : this .metadata .getAnnotationTypes ()) {
1033
+ if (!className .startsWith ("java" )) {
1034
+ try {
1035
+ result .add (getRelated (className ));
1036
+ }
1037
+ catch (Throwable ex ) {
1038
+ // An annotation not present on the classpath is being ignored
1039
+ // by the JVM's class loading -> ignore here as well.
1040
+ }
1041
+ }
1026
1042
}
1027
1043
}
1028
1044
return result ;
0 commit comments