1515import java .util .LinkedHashMap ;
1616import java .util .List ;
1717import java .util .Map ;
18+ import java .util .Objects ;
1819import java .util .Optional ;
1920import java .util .PriorityQueue ;
2021import java .util .Queue ;
@@ -538,51 +539,23 @@ public static Map<String, TypeResolver> getAllFields(AnnotationScannerContext co
538539 Map <ClassInfo , Type > chain = index .inheritanceChain (leafKlazz , leaf );
539540 Map <String , TypeResolver > properties = new LinkedHashMap <>();
540541 Deque <Map <String , Type >> stack = new ArrayDeque <>();
541- boolean skipPropertyScan = false ;
542+ boolean skipScan = false ;
542543 List <ClassInfo > descendants = new ArrayList <>(chain .size ());
543544
544545 for (Map .Entry <ClassInfo , Type > entry : chain .entrySet ()) {
545546 ClassInfo currentClass = entry .getKey ();
546547 Type currentType = entry .getValue ();
547- maybeAddResolutionParams (stack , currentType , currentClass );
548548
549- if (skipPropertyScan || (!currentType .equals (leaf ) && TypeUtil .isAllOf (context , leafKlazz , currentType ))
550- || TypeUtil .knownJavaType (currentClass .name ())) {
551- /*
552- * Do not attempt to introspect fields of Java/JDK types or if the @Schema
553- * annotation indicates the use of a `ref` for superclass fields.
554- */
555- skipPropertyScan = true ;
556- continue ;
557- }
549+ skipScan = skipCheck (skipScan , context , leaf , leafKlazz , currentType , currentClass );
558550
559- // Store all field properties
560- for (FieldInfo field : JandexUtil .fields (context , currentClass )) {
561- if (acceptField (field ) && field .name ().chars ().allMatch (Character ::isJavaIdentifierPart )) {
562- scanField (context , properties , field , stack , reference , descendants );
563- }
564- }
565-
566- for (MethodInfo method : methods (context , currentClass )) {
567- if (acceptMethod (method ) && method .name ().chars ().allMatch (Character ::isJavaIdentifierPart )) {
568- scanMethod (context , properties , method , stack , reference , descendants );
569- }
551+ if (skipScan ) {
552+ continue ;
570553 }
571554
572- for (Type type : index .interfaces (currentClass )) {
573- if (!TypeUtil .knownJavaType (type .name ())) {
574- ClassInfo clazz = index .getClass (type );
575- maybeAddResolutionParams (stack , type , clazz );
576-
577- if (clazz != null ) {
578- for (MethodInfo method : methods (context , clazz )) {
579- if (method .name ().chars ().allMatch (Character ::isJavaIdentifierPart )) {
580- scanMethod (context , properties , method , stack , reference , descendants );
581- }
582- }
583- }
584- }
585- }
555+ maybeAddResolutionParams (stack , currentType , currentClass );
556+ scanFields (context , currentClass , properties , stack , reference , descendants );
557+ scanMethods (context , currentClass , properties , stack , reference , descendants );
558+ scanInterfaces (context , currentClass , properties , stack , reference , descendants );
586559
587560 descendants .add (currentClass );
588561 }
@@ -606,6 +579,63 @@ private static void maybeAddResolutionParams(Deque<Map<String, Type>> stack, Typ
606579 }
607580 }
608581
582+ private static boolean skipCheck (boolean skip , AnnotationScannerContext context , Type leafType ,
583+ ClassInfo leafKlazz ,
584+ Type currentType ,
585+ ClassInfo currentClass ) {
586+ if (skip || (!currentType .equals (leafType ) && TypeUtil .isAllOf (context , leafKlazz , currentType ))
587+ || TypeUtil .knownJavaType (currentClass .name ())) {
588+ /*
589+ * Do not attempt to introspect fields of Java/JDK types or if the @Schema
590+ * annotation indicates the use of a `ref` for superclass fields.
591+ */
592+ skip = true ;
593+ }
594+
595+ return skip ;
596+ }
597+
598+ private static void scanFields (AnnotationScannerContext context , ClassInfo currentClass ,
599+ Map <String , TypeResolver > properties , Deque <Map <String , Type >> stack , AnnotationTarget reference ,
600+ List <ClassInfo > descendants ) {
601+ for (FieldInfo field : JandexUtil .fields (context , currentClass )) {
602+ if (acceptField (field ) && field .name ().chars ().allMatch (Character ::isJavaIdentifierPart )) {
603+ scanField (context , properties , field , stack , reference , descendants );
604+ }
605+ }
606+ }
607+
608+ private static void scanMethods (AnnotationScannerContext context , ClassInfo currentClass ,
609+ Map <String , TypeResolver > properties , Deque <Map <String , Type >> stack , AnnotationTarget reference ,
610+ List <ClassInfo > descendants ) {
611+ for (MethodInfo method : methods (context , currentClass )) {
612+ if (acceptMethod (method ) && method .name ().chars ().allMatch (Character ::isJavaIdentifierPart )) {
613+ scanMethod (context , properties , method , stack , reference , descendants );
614+ }
615+ }
616+ }
617+
618+ private static void scanInterfaces (AnnotationScannerContext context , ClassInfo currentClass ,
619+ Map <String , TypeResolver > properties , Deque <Map <String , Type >> stack , AnnotationTarget reference ,
620+ List <ClassInfo > descendants ) {
621+ AugmentedIndexView index = context .getAugmentedIndex ();
622+
623+ for (Type type : index .interfaces (currentClass )) {
624+ if (!TypeUtil .knownJavaType (type .name ())) {
625+ ClassInfo clazz = index .getClass (type );
626+ maybeAddResolutionParams (stack , type , clazz );
627+
628+ if (clazz != null ) {
629+ for (MethodInfo method : methods (context , clazz )) {
630+ if (method .name ().chars ().allMatch (Character ::isJavaIdentifierPart )) {
631+ scanMethod (context , properties , method , stack , reference , descendants );
632+ }
633+ }
634+ }
635+ }
636+ }
637+ }
638+
609639 private static List <MethodInfo > methods (AnnotationScannerContext context , ClassInfo currentClass ) {
610640 if (context .getConfig ().sortedPropertiesEnable ()) {
611641 return currentClass .methods ();
0 commit comments