@@ -483,7 +483,6 @@ public static void makeAccessible(Constructor<?> ctor) {
483483 * @param clazz the class to introspect
484484 * @param mc the callback to invoke for each method
485485 * @since 4.2
486- * @throws IllegalStateException if introspection fails
487486 * @see #doWithMethods
488487 */
489488 public static void doWithLocalMethods (Class <?> clazz , MethodCallback mc ) {
@@ -505,7 +504,6 @@ public static void doWithLocalMethods(Class<?> clazz, MethodCallback mc) {
505504 * twice, unless excluded by a {@link MethodFilter}.
506505 * @param clazz the class to introspect
507506 * @param mc the callback to invoke for each method
508- * @throws IllegalStateException if introspection fails
509507 * @see #doWithMethods(Class, MethodCallback, MethodFilter)
510508 */
511509 public static void doWithMethods (Class <?> clazz , MethodCallback mc ) {
@@ -520,7 +518,6 @@ public static void doWithMethods(Class<?> clazz, MethodCallback mc) {
520518 * @param clazz the class to introspect
521519 * @param mc the callback to invoke for each method
522520 * @param mf the filter that determines the methods to apply the callback to
523- * @throws IllegalStateException if introspection fails
524521 */
525522 public static void doWithMethods (Class <?> clazz , MethodCallback mc , MethodFilter mf ) {
526523 // Keep backing up the inheritance hierarchy.
@@ -550,7 +547,6 @@ else if (clazz.isInterface()) {
550547 * Get all declared methods on the leaf class and all superclasses.
551548 * Leaf class methods are included first.
552549 * @param leafClass the class to introspect
553- * @throws IllegalStateException if introspection fails
554550 */
555551 public static Method [] getAllDeclaredMethods (Class <?> leafClass ) {
556552 final List <Method > methods = new ArrayList <Method >(32 );
@@ -568,7 +564,6 @@ public void doWith(Method method) {
568564 * Leaf class methods are included first and while traversing the superclass hierarchy
569565 * any methods found with signatures matching a method already included are filtered out.
570566 * @param leafClass the class to introspect
571- * @throws IllegalStateException if introspection fails
572567 */
573568 public static Method [] getUniqueDeclaredMethods (Class <?> leafClass ) {
574569 final List <Method > methods = new ArrayList <Method >(32 );
@@ -609,33 +604,27 @@ public void doWith(Method method) {
609604 * interfaces, since those are effectively to be treated just like declared methods.
610605 * @param clazz the class to introspect
611606 * @return the cached array of methods
612- * @throws IllegalStateException if introspection fails
613607 * @see Class#getDeclaredMethods()
614608 */
615609 private static Method [] getDeclaredMethods (Class <?> clazz ) {
610+ Assert .notNull (clazz , "Class must not be null" );
616611 Method [] result = declaredMethodsCache .get (clazz );
617612 if (result == null ) {
618- try {
619- Method [] declaredMethods = clazz .getDeclaredMethods ();
620- List <Method > defaultMethods = findConcreteMethodsOnInterfaces (clazz );
621- if (defaultMethods != null ) {
622- result = new Method [declaredMethods .length + defaultMethods .size ()];
623- System .arraycopy (declaredMethods , 0 , result , 0 , declaredMethods .length );
624- int index = declaredMethods .length ;
625- for (Method defaultMethod : defaultMethods ) {
626- result [index ] = defaultMethod ;
627- index ++;
628- }
629- }
630- else {
631- result = declaredMethods ;
613+ Method [] declaredMethods = clazz .getDeclaredMethods ();
614+ List <Method > defaultMethods = findConcreteMethodsOnInterfaces (clazz );
615+ if (defaultMethods != null ) {
616+ result = new Method [declaredMethods .length + defaultMethods .size ()];
617+ System .arraycopy (declaredMethods , 0 , result , 0 , declaredMethods .length );
618+ int index = declaredMethods .length ;
619+ for (Method defaultMethod : defaultMethods ) {
620+ result [index ] = defaultMethod ;
621+ index ++;
632622 }
633- declaredMethodsCache .put (clazz , (result .length == 0 ? NO_METHODS : result ));
634623 }
635- catch (Throwable ex ) {
636- throw new IllegalStateException ("Failed to introspect Class [" + clazz +
637- "] from ClassLoader [" + clazz .getClassLoader () + "]" , ex );
624+ else {
625+ result = declaredMethods ;
638626 }
627+ declaredMethodsCache .put (clazz , (result .length == 0 ? NO_METHODS : result ));
639628 }
640629 return result ;
641630 }
@@ -661,7 +650,6 @@ private static List<Method> findConcreteMethodsOnInterfaces(Class<?> clazz) {
661650 * @param clazz the target class to analyze
662651 * @param fc the callback to invoke for each field
663652 * @since 4.2
664- * @throws IllegalStateException if introspection fails
665653 * @see #doWithFields
666654 */
667655 public static void doWithLocalFields (Class <?> clazz , FieldCallback fc ) {
@@ -680,7 +668,6 @@ public static void doWithLocalFields(Class<?> clazz, FieldCallback fc) {
680668 * class hierarchy to get all declared fields.
681669 * @param clazz the target class to analyze
682670 * @param fc the callback to invoke for each field
683- * @throws IllegalStateException if introspection fails
684671 */
685672 public static void doWithFields (Class <?> clazz , FieldCallback fc ) {
686673 doWithFields (clazz , fc , null );
@@ -692,7 +679,6 @@ public static void doWithFields(Class<?> clazz, FieldCallback fc) {
692679 * @param clazz the target class to analyze
693680 * @param fc the callback to invoke for each field
694681 * @param ff the filter that determines the fields to apply the callback to
695- * @throws IllegalStateException if introspection fails
696682 */
697683 public static void doWithFields (Class <?> clazz , FieldCallback fc , FieldFilter ff ) {
698684 // Keep backing up the inheritance hierarchy.
@@ -720,20 +706,14 @@ public static void doWithFields(Class<?> clazz, FieldCallback fc, FieldFilter ff
720706 * in order to avoid the JVM's SecurityManager check and defensive array copying.
721707 * @param clazz the class to introspect
722708 * @return the cached array of fields
723- * @throws IllegalStateException if introspection fails
724709 * @see Class#getDeclaredFields()
725710 */
726711 private static Field [] getDeclaredFields (Class <?> clazz ) {
712+ Assert .notNull (clazz , "Class must not be null" );
727713 Field [] result = declaredFieldsCache .get (clazz );
728714 if (result == null ) {
729- try {
730- result = clazz .getDeclaredFields ();
731- declaredFieldsCache .put (clazz , (result .length == 0 ? NO_FIELDS : result ));
732- }
733- catch (Throwable ex ) {
734- throw new IllegalStateException ("Failed to introspect Class [" + clazz +
735- "] from ClassLoader [" + clazz .getClassLoader () + "]" , ex );
736- }
715+ result = clazz .getDeclaredFields ();
716+ declaredFieldsCache .put (clazz , (result .length == 0 ? NO_FIELDS : result ));
737717 }
738718 return result ;
739719 }
@@ -742,7 +722,6 @@ private static Field[] getDeclaredFields(Class<?> clazz) {
742722 * Given the source object and the destination, which must be the same class
743723 * or a subclass, copy all fields, including inherited fields. Designed to
744724 * work on objects with public no-arg constructors.
745- * @throws IllegalStateException if introspection fails
746725 */
747726 public static void shallowCopyFieldState (final Object src , final Object dest ) {
748727 if (src == null ) {
0 commit comments