Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/main/java/org/codehaus/gmavenplus/util/ReflectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static Constructor<?> findConstructor(final Class<?> clazz, final Class<?
}
searchType = searchType.getSuperclass();
}
throw new IllegalArgumentException("Unable to find constructor " + clazz.getName() + "(" + Arrays.toString(paramTypes).replaceAll("^\\[", "").replaceAll("]$", "").replaceAll("class ", "") + ").");
throw new IllegalArgumentException("Unable to find constructor " + clazz.getName() + "(" + formatParameterTypes(paramTypes) + ").");
}

/**
Expand Down Expand Up @@ -107,7 +107,7 @@ public static Method findMethod(final Class<?> clazz, final String name, final C
}
searchType = searchType.getSuperclass();
}
throw new IllegalArgumentException("Unable to find method " + clazz.getName() + "." + name + "(" + Arrays.toString(paramTypes).replaceAll("^\\[", "").replaceAll("]$", "").replaceAll("class ", "") + ").");
throw new IllegalArgumentException("Unable to find method " + clazz.getName() + "." + name + "(" + formatParameterTypes(paramTypes) + ").");
}

/**
Expand Down Expand Up @@ -245,6 +245,30 @@ private static Method[] getDeclaredMethods(Class<?> clazz) {
return result;
}

private static String formatParameterTypes(final Class<?>[] paramTypes) {
if (paramTypes == null) {
return "null";
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < paramTypes.length; i++) {
if (paramTypes[i] == null) {
sb.append("null");
} else {
String s = paramTypes[i].toString();
final String classPrefix = "class ";
if (s.startsWith(classPrefix)) {
sb.append(s.substring(classPrefix.length()));
} else {
sb.append(s);
}
}
if (i < paramTypes.length - 1) {
sb.append(", ");
}
}
return sb.toString();
}

private static List<Method> findConcreteMethodsOnInterfaces(Class<?> clazz) {
List<Method> result = null;
for (Class<?> ifc : clazz.getInterfaces()) {
Expand Down
Loading