protected void assertDeclaredConstructor(Class<?> clazz, Constructor<?> constructor, ClassInfo classInfo) throws Throwable
{
getLog().debug("Checking constructor " + Arrays.asList(constructor.getParameterTypes()));
TypeInfoFactory factory = getTypeInfoFactory();
Type[] paramClasses = constructor.getGenericParameterTypes();
// HACK: This is to workaround a bug in Sun's compiler related to enum constructors
// having no generic parameters?
Type[] parameterTypes = constructor.getParameterTypes();
if (paramClasses.length != parameterTypes.length)
paramClasses = parameterTypes;
TypeInfo[] paramTypes = new TypeInfo[paramClasses.length];
for (int i = 0; i < paramClasses.length; ++i)
paramTypes[i] = factory.getTypeInfo(paramClasses[i]);
ConstructorInfo constructorInfo = classInfo.getDeclaredConstructor(paramTypes);
assertNotNull(constructorInfo);
TypeInfo[] actualParamTypes = constructorInfo.getParameterTypes();
for (int i = 0; i < paramTypes.length; ++i)
assertTypeEquals(clazz + " constructorParameter" + i, paramTypes[i], actualParamTypes[i]);
Class<?>[] exceptionClasses = constructor.getExceptionTypes();
TypeInfo[] expectedExceptionTypes = new TypeInfo[exceptionClasses.length];
for (int i = 0; i < exceptionClasses.length; ++i)
expectedExceptionTypes[i] = factory.getTypeInfo(exceptionClasses[i]);
TypeInfo[] actualExceptionTypes = constructorInfo.getExceptionTypes();
for (int i = 0; i < exceptionClasses.length; ++i)
assertTypeEquals(clazz + " constructorException" + i, expectedExceptionTypes[i], actualExceptionTypes[i]);
assertEquals(classInfo, constructorInfo.getDeclaringClass());
assertEquals(constructor.getModifiers(), constructorInfo.getModifiers());