better message when dependency is interface

This commit is contained in:
Stepan Koltsov
2012-03-15 00:14:18 +04:00
parent 9524b48676
commit 245a4f079c
@@ -339,6 +339,10 @@ public class DependencyInjectorGenerator {
private void initializeByConstructorCall(Field field, Field neededFor) {
Class<?> type = field.getType();
if (type.isInterface()) {
throw new IllegalArgumentException("cannot instantiate interface: " + type.getName() + " needed for " + neededFor);
}
// Look for constructor
Constructor<?>[] constructors = type.getConstructors();
if (constructors.length == 0 || !Modifier.isPublic(constructors[0].getModifiers())) {