static void throwExceptionWhenMultipleConstructorMatchesFound ( Constructor < ? > [ ] constructors ) { if ( constructors == null || constructors . length < 2 ) { throw new IllegalArgumentException ( "Internal error: throwExceptionWhenMultipleConstructorMatchesFound needs at least two constructors." ) ; } StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Several matching constructors found, please specify the argument parameter types so that PowerMock can determine which method you're referring to.\n" ) ; sb . append ( "Matching constructors in class " ) . append ( constructors [ 0 ] . getDeclaringClass ( ) . getName ( ) ) . append ( " were:\n" ) ; for ( Constructor < ? > constructor : constructors ) { sb . append ( constructor . getName ( ) ) . append ( "( " ) ; final Class < ? > [ ] parameterTypes = constructor . getParameterTypes ( ) ; for ( Class < ? > paramType : parameterTypes ) { sb . append ( paramType . getName ( ) ) . append ( ".class " ) ; } sb . append ( ")\n" ) ; } throw new TooManyConstructorsFoundException ( sb . toString ( ) ) ; }
Throw exception when multiple constructor matches found .