@@ -378,30 +378,7 @@ private void resolveCreators()
378
378
List <AnnotatedMethod > creatorMethods = null ;
379
379
380
380
// Then static methods which are potential factory methods
381
-
382
- Method [] classMethods ;
383
- try {
384
- classMethods = _class .getDeclaredMethods ();
385
- }catch (final NoClassDefFoundError ex ){
386
- // One of the methods had a class that was not found in the cls.getClassLoader.
387
- // Maybe the developer was nice and has a different class loader for this context.
388
- final ClassLoader loader = Thread .currentThread ().getContextClassLoader ();
389
- if (loader == null ){
390
- // Nope... this is going to end poorly
391
- throw ex ;
392
- }
393
- final Class <?> contextClass ;
394
- try {
395
- contextClass = loader .loadClass (_class .getName ());
396
- }
397
- catch (ClassNotFoundException e ) {
398
- //ex.addSuppressed(e); Not until 1.7
399
- throw ex ;
400
- }
401
- classMethods = contextClass .getDeclaredMethods (); // Cross fingers
402
- }
403
-
404
- for (Method m : classMethods ) {
381
+ for (Method m : _findClassMethods (_class )) {
405
382
if (!Modifier .isStatic (m .getModifiers ())) {
406
383
continue ;
407
384
}
@@ -432,7 +409,7 @@ private void resolveCreators()
432
409
}
433
410
_creatorsResolved = true ;
434
411
}
435
-
412
+
436
413
/**
437
414
* Method for resolving member method information: aggregating all non-static methods
438
415
* and combining annotations (to implement method-annotation inheritance)
@@ -619,29 +596,8 @@ protected void _addMemberMethods(Class<?> cls, AnnotatedMethodMap methods,
619
596
if (cls == null ) { // just so caller need not check when passing super-class
620
597
return ;
621
598
}
622
- Method [] classMethods ;
623
- try {
624
- classMethods = cls .getDeclaredMethods ();
625
- }catch (final NoClassDefFoundError ex ){
626
- // One of the methods had a class that was not found in the cls.getClassLoader.
627
- // Maybe the developer was nice and has a different class loader for this context.
628
- final ClassLoader loader = Thread .currentThread ().getContextClassLoader ();
629
- if (loader == null ) {
630
- // Nope... this is going to end poorly
631
- throw ex ;
632
- }
633
- final Class <?> contextClass ;
634
- try {
635
- contextClass = loader .loadClass (cls .getName ());
636
- }
637
- catch (ClassNotFoundException e ) {
638
- //ex.addSuppressed(e); Not until 1.7
639
- throw ex ;
640
- }
641
- classMethods = contextClass .getDeclaredMethods (); // Cross fingers
642
- }
643
599
// then methods from the class itself
644
- for (Method m : classMethods ) {
600
+ for (Method m : _findClassMethods ( cls ) ) {
645
601
if (!_isIncludableMemberMethod (m )) {
646
602
continue ;
647
603
}
@@ -1056,11 +1012,41 @@ protected void _addMixUnders(Method src, AnnotatedMethod target) {
1056
1012
_addAnnotationsIfNotPresent (target , src .getDeclaredAnnotations ());
1057
1013
}
1058
1014
1059
- private final boolean _isAnnotationBundle (Annotation ann )
1060
- {
1061
- return (_annotationIntrospector != null ) && _annotationIntrospector .isAnnotationBundle (ann );
1062
- }
1063
-
1015
+ private final boolean _isAnnotationBundle (Annotation ann ) {
1016
+ return (_annotationIntrospector != null ) && _annotationIntrospector .isAnnotationBundle (ann );
1017
+ }
1018
+
1019
+ /**
1020
+ * Helper method that gets methods declared in given class; usually a simple thing,
1021
+ * but sometimes (as per [databind#785]) more complicated, depending on classloader
1022
+ * setup.
1023
+ *
1024
+ * @since 2.4.7
1025
+ */
1026
+ protected Method [] _findClassMethods (Class <?> cls )
1027
+ {
1028
+ try {
1029
+ return cls .getDeclaredMethods ();
1030
+ } catch (final NoClassDefFoundError ex ) {
1031
+ // One of the methods had a class that was not found in the cls.getClassLoader.
1032
+ // Maybe the developer was nice and has a different class loader for this context.
1033
+ final ClassLoader loader = Thread .currentThread ().getContextClassLoader ();
1034
+ if (loader == null ){
1035
+ // Nope... this is going to end poorly
1036
+ throw ex ;
1037
+ }
1038
+ final Class <?> contextClass ;
1039
+ try {
1040
+ contextClass = loader .loadClass (cls .getName ());
1041
+ } catch (ClassNotFoundException e ) {
1042
+ // !!! TODO: 08-May-2015, tatu: Chain appropriately once we have JDK7 as baseline
1043
+ //ex.addSuppressed(e); Not until 1.7
1044
+ throw ex ;
1045
+ }
1046
+ return contextClass .getDeclaredMethods (); // Cross fingers
1047
+ }
1048
+ }
1049
+
1064
1050
/*
1065
1051
/**********************************************************
1066
1052
/* Other methods
0 commit comments