### Question:
MethodUtils { public static Method getAssignmentCompatibleMethod( Class<?> clazz, String candidateMethodName, Class<?>[] candidateParameterTypes ) throws NoSuchMethodException { if ( LOG.isDebugEnabled() ) { StringBuilder buf = new StringBuilder(); buf.append( "call to getAssignmentCompatibleMethod(): \n\tclazz = " ); buf.append( clazz.getName() ); buf.append( "\n\tcandidateMethodName = " ); buf.append( candidateMethodName ); buf.append( "\n\tcandidateParameterTypes = " ); for ( Class<?> argClass : candidateParameterTypes ) { buf.append( "\n\t\t" ); buf.append( argClass.getName() ); } if ( LOG.isDebugEnabled() ) { LOG.debug( buf.toString() ); } } try { Method exactMethod = clazz.getMethod( candidateMethodName, candidateParameterTypes ); if ( exactMethod != null ) { return exactMethod; } } catch ( Exception e ) { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_17009_NO_EXACT_MATCH, candidateMethodName, e ) ); } } Method[] methods = clazz.getMethods(); for ( int mx = 0; mx < methods.length; mx++ ) { if ( !candidateMethodName.equals( methods[mx].getName() ) ) { continue; } Class<?>[] parameterTypes = methods[mx].getParameterTypes(); if ( parameterTypes.length != candidateParameterTypes.length ) { continue; } for ( int px = 0; px < parameterTypes.length; px++ ) { if ( !parameterTypes[px].isAssignableFrom( candidateParameterTypes[px] ) ) { break; } } return methods[mx]; } throw new NoSuchMethodException( clazz.getName() + "." + candidateMethodName + "(" + Arrays.toString( candidateParameterTypes ) + ")" ); } private  MethodUtils(); static Method getAssignmentCompatibleMethod( Class<?> clazz,
        String candidateMethodName,
        Class<?>[] candidateParameterTypes
        );  }### Answer:
@Test public void testSameBehaviourOfStandardGetMethod() { Method m1 = null; Method m2 = null; try { m1 = TestClass.class.getMethod( "methodA", new Class[] { String.class } ); } catch ( SecurityException e ) { e.printStackTrace(); } catch ( NoSuchMethodException e ) { e.printStackTrace(); } try { m2 = MethodUtils.getAssignmentCompatibleMethod( TestClass.class, "methodA", new Class[] { String.class } ); } catch ( NoSuchMethodException e ) { e.printStackTrace(); } assertEquals( m1, m2 ); }
@Test public void testNewBehaviourOfAssignmentCompatibleGetMethod() { Method m2 = null; try { TestClass.class.getMethod( "methodB", new Class[] { ArrayList.class } ); fail( "We should not have come here." ); } catch ( SecurityException e ) { e.printStackTrace(); } catch ( NoSuchMethodException e ) { assertNotNull( e ); } try { m2 = MethodUtils.getAssignmentCompatibleMethod( TestClass.class, "methodB", new Class[] { ArrayList.class } ); } catch ( NoSuchMethodException e ) { e.printStackTrace(); } assertNotNull( m2 ); }