private static RegistryServer newInstance(Object... parameters) { if (defaultRegistryClass == null || allConstructorsParameterTypes == null) { throw new UnsupportedOperationException("Unsupported default registry"); } // 根据JLS方法调用的静态分派规则查找最匹配的方法parameterTypes Class<?>[] parameterTypes = Reflects.findMatchingParameterTypes(allConstructorsParameterTypes, parameters); if (parameterTypes == null) { throw new IllegalArgumentException("Parameter types"); } try { @SuppressWarnings("JavaReflectionMemberAccess") Constructor<RegistryServer> c = defaultRegistryClass.getConstructor(parameterTypes); c.setAccessible(true); return c.newInstance(parameters); } catch (Exception e) { ThrowUtil.throwException(e); } return null; // should never get here } }
private static RegistryServer newInstance(Object... parameters) { if (defaultRegistryClass == null || allConstructorsParameterTypes == null) { throw new UnsupportedOperationException("Unsupported default registry"); } // 根据JLS方法调用的静态分派规则查找最匹配的方法parameterTypes Class<?>[] parameterTypes = Reflects.findMatchingParameterTypes(allConstructorsParameterTypes, parameters); if (parameterTypes == null) { throw new IllegalArgumentException("Parameter types"); } try { @SuppressWarnings("JavaReflectionMemberAccess") Constructor<RegistryServer> c = defaultRegistryClass.getConstructor(parameterTypes); c.setAccessible(true); return c.newInstance(parameters); } catch (Exception e) { ThrowUtil.throwException(e); } return null; // should never get here } }
private static RegistryServer newInstance(Object... parameters) { if (defaultRegistryClass == null || allConstructorsParameterTypes == null) { throw new UnsupportedOperationException("Unsupported default registry"); } // 根据JLS方法调用的静态分派规则查找最匹配的方法parameterTypes Class<?>[] parameterTypes = Reflects.findMatchingParameterTypes(allConstructorsParameterTypes, parameters); if (parameterTypes == null) { throw new IllegalArgumentException("Parameter types"); } try { @SuppressWarnings("JavaReflectionMemberAccess") Constructor<RegistryServer> c = defaultRegistryClass.getConstructor(parameterTypes); c.setAccessible(true); return c.newInstance(parameters); } catch (Exception e) { ThrowUtil.throwException(e); } return null; // should never get here } }
private static RegistryServer newInstance(Object... parameters) { if (defaultRegistryClass == null || allConstructorsParameterTypes == null) { throw new UnsupportedOperationException("Unsupported default registry"); } // 根据JLS方法调用的静态分派规则查找最匹配的方法parameterTypes Class<?>[] parameterTypes = Reflects.findMatchingParameterTypes(allConstructorsParameterTypes, parameters); if (parameterTypes == null) { throw new IllegalArgumentException("Parameter types"); } try { @SuppressWarnings("JavaReflectionMemberAccess") Constructor<RegistryServer> c = defaultRegistryClass.getConstructor(parameterTypes); c.setAccessible(true); return c.newInstance(parameters); } catch (Exception e) { ThrowUtil.throwException(e); } return null; // should never get here } }