@@ -483,7 +483,6 @@ public static void makeAccessible(Constructor<?> ctor) {
483
483
* @param clazz the class to introspect
484
484
* @param mc the callback to invoke for each method
485
485
* @since 4.2
486
- * @throws IllegalStateException if introspection fails
487
486
* @see #doWithMethods
488
487
*/
489
488
public static void doWithLocalMethods (Class <?> clazz , MethodCallback mc ) {
@@ -505,7 +504,6 @@ public static void doWithLocalMethods(Class<?> clazz, MethodCallback mc) {
505
504
* twice, unless excluded by a {@link MethodFilter}.
506
505
* @param clazz the class to introspect
507
506
* @param mc the callback to invoke for each method
508
- * @throws IllegalStateException if introspection fails
509
507
* @see #doWithMethods(Class, MethodCallback, MethodFilter)
510
508
*/
511
509
public static void doWithMethods (Class <?> clazz , MethodCallback mc ) {
@@ -520,7 +518,6 @@ public static void doWithMethods(Class<?> clazz, MethodCallback mc) {
520
518
* @param clazz the class to introspect
521
519
* @param mc the callback to invoke for each method
522
520
* @param mf the filter that determines the methods to apply the callback to
523
- * @throws IllegalStateException if introspection fails
524
521
*/
525
522
public static void doWithMethods (Class <?> clazz , MethodCallback mc , MethodFilter mf ) {
526
523
// Keep backing up the inheritance hierarchy.
@@ -550,7 +547,6 @@ else if (clazz.isInterface()) {
550
547
* Get all declared methods on the leaf class and all superclasses.
551
548
* Leaf class methods are included first.
552
549
* @param leafClass the class to introspect
553
- * @throws IllegalStateException if introspection fails
554
550
*/
555
551
public static Method [] getAllDeclaredMethods (Class <?> leafClass ) {
556
552
final List <Method > methods = new ArrayList <Method >(32 );
@@ -568,7 +564,6 @@ public void doWith(Method method) {
568
564
* Leaf class methods are included first and while traversing the superclass hierarchy
569
565
* any methods found with signatures matching a method already included are filtered out.
570
566
* @param leafClass the class to introspect
571
- * @throws IllegalStateException if introspection fails
572
567
*/
573
568
public static Method [] getUniqueDeclaredMethods (Class <?> leafClass ) {
574
569
final List <Method > methods = new ArrayList <Method >(32 );
@@ -609,33 +604,27 @@ public void doWith(Method method) {
609
604
* interfaces, since those are effectively to be treated just like declared methods.
610
605
* @param clazz the class to introspect
611
606
* @return the cached array of methods
612
- * @throws IllegalStateException if introspection fails
613
607
* @see Class#getDeclaredMethods()
614
608
*/
615
609
private static Method [] getDeclaredMethods (Class <?> clazz ) {
610
+ Assert .notNull (clazz , "Class must not be null" );
616
611
Method [] result = declaredMethodsCache .get (clazz );
617
612
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 ++;
632
622
}
633
- declaredMethodsCache .put (clazz , (result .length == 0 ? NO_METHODS : result ));
634
623
}
635
- catch (Throwable ex ) {
636
- throw new IllegalStateException ("Failed to introspect Class [" + clazz +
637
- "] from ClassLoader [" + clazz .getClassLoader () + "]" , ex );
624
+ else {
625
+ result = declaredMethods ;
638
626
}
627
+ declaredMethodsCache .put (clazz , (result .length == 0 ? NO_METHODS : result ));
639
628
}
640
629
return result ;
641
630
}
@@ -661,7 +650,6 @@ private static List<Method> findConcreteMethodsOnInterfaces(Class<?> clazz) {
661
650
* @param clazz the target class to analyze
662
651
* @param fc the callback to invoke for each field
663
652
* @since 4.2
664
- * @throws IllegalStateException if introspection fails
665
653
* @see #doWithFields
666
654
*/
667
655
public static void doWithLocalFields (Class <?> clazz , FieldCallback fc ) {
@@ -680,7 +668,6 @@ public static void doWithLocalFields(Class<?> clazz, FieldCallback fc) {
680
668
* class hierarchy to get all declared fields.
681
669
* @param clazz the target class to analyze
682
670
* @param fc the callback to invoke for each field
683
- * @throws IllegalStateException if introspection fails
684
671
*/
685
672
public static void doWithFields (Class <?> clazz , FieldCallback fc ) {
686
673
doWithFields (clazz , fc , null );
@@ -692,7 +679,6 @@ public static void doWithFields(Class<?> clazz, FieldCallback fc) {
692
679
* @param clazz the target class to analyze
693
680
* @param fc the callback to invoke for each field
694
681
* @param ff the filter that determines the fields to apply the callback to
695
- * @throws IllegalStateException if introspection fails
696
682
*/
697
683
public static void doWithFields (Class <?> clazz , FieldCallback fc , FieldFilter ff ) {
698
684
// Keep backing up the inheritance hierarchy.
@@ -720,20 +706,14 @@ public static void doWithFields(Class<?> clazz, FieldCallback fc, FieldFilter ff
720
706
* in order to avoid the JVM's SecurityManager check and defensive array copying.
721
707
* @param clazz the class to introspect
722
708
* @return the cached array of fields
723
- * @throws IllegalStateException if introspection fails
724
709
* @see Class#getDeclaredFields()
725
710
*/
726
711
private static Field [] getDeclaredFields (Class <?> clazz ) {
712
+ Assert .notNull (clazz , "Class must not be null" );
727
713
Field [] result = declaredFieldsCache .get (clazz );
728
714
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 ));
737
717
}
738
718
return result ;
739
719
}
@@ -742,7 +722,6 @@ private static Field[] getDeclaredFields(Class<?> clazz) {
742
722
* Given the source object and the destination, which must be the same class
743
723
* or a subclass, copy all fields, including inherited fields. Designed to
744
724
* work on objects with public no-arg constructors.
745
- * @throws IllegalStateException if introspection fails
746
725
*/
747
726
public static void shallowCopyFieldState (final Object src , final Object dest ) {
748
727
if (src == null ) {
0 commit comments