jodd-petite/src/main/java/jodd/petite/PetiteBeans.java
private <T> T newInternalInstance(final Class<T> type, final PetiteContainer petiteContainer) throws Exception {
		T t = null;

		// first try ctor(PetiteContainer)
		try {
			Constructor<T> ctor = type.getConstructor(PetiteContainer.class);
			t = ctor.newInstance(petiteContainer);
		} catch (NoSuchMethodException nsmex) {
			// ignore
		}

		// if first try failed, try default ctor
		if (t == null) {
			return ClassUtil.newInstance(type);
		}

		return t;
	}
private <T> T newInternalInstance(final Class<T> type, final PetiteContainer petiteContainer) throws Exception {
		T t = null;

		// first try ctor(PetiteContainer)
		try {
			Constructor<T> ctor = type.getConstructor(PetiteContainer.class);
			t = ctor.newInstance(petiteContainer);
		} catch (NoSuchMethodException nsmex) {
			// ignore
		}

		// if first try failed, try default ctor
		if (t == null) {
			return ClassUtil.newInstance(type);
		}

		return t;
	}
private < T > T newInternalInstance ( final Class < T > type , final PetiteContainer petiteContainer ) throws Exception { T t = null ; // first try ctor(PetiteContainer) try { Constructor < T > ctor = type . getConstructor ( PetiteContainer . class ) ; t = ctor . newInstance ( petiteContainer ) ; } catch ( NoSuchMethodException nsmex ) { // ignore } // if first try failed, try default ctor if ( t == null ) { return ClassUtil . newInstance ( type ) ; } return t ; }
Creates new instance of given type. In the first try, it tries to use
constructor with a {@link PetiteContainer}. If that files, uses default
constructor to builds an instance.
Creates new instance of given type . In the first try it tries to use constructor with a {