protected void createConstructorRepository(final Class klass) {
if (klass == null) {
throw new IllegalArgumentException("class can not be null");
}
Constructor[] constructors = klass.getDeclaredConstructors();
TIntObjectHashMap constructorMap = new TIntObjectHashMap(constructors.length);
for (int i = 0; i < constructors.length; i++) {
Constructor constructor1 = constructors[i];
Constructor prefixedConstructor = constructor1;
Constructor wrapperConstructor = constructor1;
for (int j = 0; j < constructors.length; j++) {
Constructor constructor2 = constructors[j];
Class[] parameterTypes1 = constructor1.getParameterTypes();
Class[] parameterTypes2 = constructor2.getParameterTypes();
if (!constructor2.getName().equals(constructor1.getName())) {
continue;
}
if (parameterTypes1.length == parameterTypes2.length) {
continue;
}
else if (parameterTypes1.length < parameterTypes2.length &&
parameterTypes1.length == parameterTypes2.length - 1) {
boolean match = true;
for (int k = 0; k < parameterTypes1.length; k++) {
if (parameterTypes1[k] != parameterTypes2[k]) {
match = false;
break;
}
}
if (parameterTypes2[parameterTypes1.length].getName().
equals(TransformationUtil.JOIN_POINT_MANAGER_CLASS)) {
match = true;
}
if (!match) {
continue;
}
wrapperConstructor = constructor1;
prefixedConstructor = constructor2;
break;
}
else if (parameterTypes2.length < parameterTypes1.length &&
parameterTypes2.length == parameterTypes1.length - 1) {
boolean match = true;
for (int k = 0; k < parameterTypes2.length; k++) {
if (parameterTypes2[k] != parameterTypes1[k]) {
match = false;
break;
}
}
if (parameterTypes1[parameterTypes2.length].getName().
equals(TransformationUtil.JOIN_POINT_MANAGER_CLASS)) {
match = true;
}
if (!match) {
continue;
}
wrapperConstructor = constructor2;
prefixedConstructor = constructor1;
break;
}
}
// create a constructor tuple with 'wrapper constructor' and 'prefixed constructor'
ConstructorTuple constructorTuple = new ConstructorTuple(wrapperConstructor, prefixedConstructor);
// map the tuple to the hash for the 'wrapper constructor'
int constructorHash = TransformationUtil.calculateHash(wrapperConstructor);
constructorMap.put(constructorHash, constructorTuple);
}
synchronized (m_constructors) {
m_constructors.put(klass, constructorMap);
}