2424import java .lang .ref .WeakReference ;
2525import java .lang .reflect .Method ;
2626import java .lang .reflect .Modifier ;
27+ import java .util .Objects ;
2728
2829/**
2930 * A MappedPropertyDescriptor describes one mapped property.
@@ -50,13 +51,15 @@ public class MappedPropertyDescriptor extends PropertyDescriptor {
5051 * See http://issues.apache.org/jira/browse/BEANUTILS-291
5152 */
5253 private static class MappedMethodReference {
54+
5355 private String className ;
5456 private String methodName ;
5557 private Reference <Method > methodRef ;
5658 private Reference <Class <?>> classRef ;
5759 private Reference <Class <?>> writeParamTypeRef0 ;
5860 private Reference <Class <?>> writeParamTypeRef1 ;
5961 private String [] writeParamClassNames ;
62+
6063 MappedMethodReference (final Method m ) {
6164 if (m != null ) {
6265 className = m .getDeclaringClass ().getName ();
@@ -91,10 +94,7 @@ private Method get() {
9194 classRef = new WeakReference <>(clazz );
9295 }
9396 }
94- if (clazz == null ) {
95- throw new RuntimeException ("Method " + methodName + " for " +
96- className + " could not be reconstructed - class reference has gone" );
97- }
97+ Objects .requireNonNull (clazz , () -> "Method " + methodName + " for " + className + " could not be reconstructed - class reference has gone" );
9898 Class <?>[] paramTypes = null ;
9999 if (writeParamClassNames != null ) {
100100 paramTypes = new Class [2 ];
@@ -122,8 +122,7 @@ private Method get() {
122122 // Un-comment following line for testing
123123 // System.out.println("Recreated Method " + methodName + " for " + className);
124124 } catch (final NoSuchMethodException e ) {
125- throw new RuntimeException ("Method " + methodName + " for " +
126- className + " could not be reconstructed - method not found" );
125+ throw new RuntimeException ("Method " + methodName + " for " + className + " could not be reconstructed - method not found" , e );
127126 }
128127 methodRef = new SoftReference <>(m );
129128 }
0 commit comments