private static Object invokeNullaryFactoryMethod ( final String fqcn , final String methodName ) { try { final Class < ? > type = Class . forName ( fqcn ) ; final Method method = type . getMethod ( methodName ) ; return method . invoke ( null ) ; // any exception is really unexpected since the type name has // already been verified } catch ( final Exception e ) { throw new InstantiationException ( String . format ( "Could not create %s#%s(): %s" , fqcn , methodName , e ) , e ) ; } }
Invokes a nullary static factory method using reflection to stay backwards - compatible with older JDKs .