public Constructor<T> getConstructor(Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException 获取参数列表匹配的公共构造器public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException 获取参数列表匹配的所有构造器@CallerSensitive public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); } return getReflectionFactory().copyConstructor( getConstructor0(parameterTypes, Member.DECLARED)); } @CallerSensitive public Constructor<T> getConstructor(Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); } return getReflectionFactory().copyConstructor( getConstructor0(parameterTypes, Member.PUBLIC)); }
getConstructor 和 getDeclaredConstructor区别
最新推荐文章于 2024-08-12 07:25:18 发布