Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ReflectionHelper {

public static void echoError(String message) {
if (hasInitialized) {
Debug.echoError("[ReflectionHelper]" + message);
Debug.echoError("[ReflectionHelper] " + message);
}
else {
System.err.println("[Denizen] [ReflectionHelper]: " + message);
Expand Down Expand Up @@ -158,11 +158,31 @@ public static MethodHandle getConstructor(Class<?> clazz, Class<?>... params) {
catch (Throwable ex) {
echoError(ex);
}
echoError("[ReflectionHelper]: Cannot find constructor for class '" + clazz.getCanonicalName() + "' with params: ["
echoError("Cannot find constructor for class '" + clazz.getCanonicalName() + "' with params: ["
+ Arrays.stream(params).map(Class::getCanonicalName).collect(Collectors.joining(", ")) + "]");
return null;
}

public static Class<?> getClass(String className) {
try {
return Class.forName(className);
}
catch (ClassNotFoundException e) {
echoError("Reflection class missing - Tried to find class '" + className + "'.");
return null;
}
}

public static Class<?> getClassOrThrow(String className) {
try {
return Class.forName(className);
}
catch (ClassNotFoundException e) {
echoError("Reflection class missing - Tried to find class '" + className + "'.");
throw new TypeNotPresentException(className, e);
}
}

public static MethodHandle getMethodHandle(Class<?> clazz, String method, Class<?>... params) {
try {
return LOOKUP.unreflect(getMethod(clazz, method, params));
Expand Down Expand Up @@ -198,7 +218,7 @@ public static MethodHandle getFinalSetter(Class<?> clazz, String field, Class ex
return null;
}
if (expected != null && f.getType() != expected) {
echoError("[ReflectionHelper] field type mismatch in getFinalSetter: field '" + field + "' in class '" + clazz.getName() + "' returns type '" + f.getType().getCanonicalName() + "' but expected '" + expected.getCanonicalName() + "'");
echoError("field type mismatch in getFinalSetter: field '" + field + "' in class '" + clazz.getName() + "' returns type '" + f.getType().getCanonicalName() + "' but expected '" + expected.getCanonicalName() + "'");
}
int mod = f.getModifiers();
try {
Expand Down