public static TypeBinding[] substitute(Substitution substitution,TypeBinding[] originalTypes){
  if (originalTypes == null)   return null;
  TypeBinding[] substitutedTypes=originalTypes;
  for (int i=0, length=originalTypes.length; i < length; i++) {
    TypeBinding originalType=originalTypes[i];
    TypeBinding substitutedParameter=substitute(substitution,originalType);
    if (substitutedParameter != originalType) {
      if (substitutedTypes == originalTypes) {
        System.arraycopy(originalTypes,0,substitutedTypes=new TypeBinding[length],0,i);
      }
      substitutedTypes[i]=substitutedParameter;
    }
 else     if (substitutedTypes != originalTypes) {
      substitutedTypes[i]=originalType;
    }
  }
  return substitutedTypes;
}

public static TypeBinding [ ] substitute ( Substitution substitution , TypeBinding [ ] originalTypes ) { if ( originalTypes == null ) return null ; TypeBinding [ ] substitutedTypes = originalTypes ; for ( int i = 0 , length = originalTypes . length ; i < length ; i ++ ) { TypeBinding originalType = originalTypes [ i ] ; TypeBinding substitutedParameter = substitute ( substitution , originalType ) ; if ( substitutedParameter != originalType ) { if ( substitutedTypes == originalTypes ) { System . arraycopy ( originalTypes , 0 , substitutedTypes = new TypeBinding [ length ] , 0 , i ) ; } substitutedTypes [ i ] = substitutedParameter ; } else if ( substitutedTypes != originalTypes ) { substitutedTypes [ i ] = originalType ; } } return substitutedTypes ; }
returns an array of types , where original types got substituted given a substitution . only allocate an array if anything is different .
