Skip to content

Commit

Permalink
Reorder methods in RefasterIntrospection
Browse files Browse the repository at this point in the history
  • Loading branch information
rickie authored and Stephan202 committed Sep 29, 2022
1 parent 8c1cf12 commit 67127ae
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,11 @@ static ImmutableList<UExpression> getExpressions(UAnyOf tree) {
return invokeMethod(METHOD_UANY_OF_EXPRESSIONS, tree);
}

@SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"})
private static <T> T invokeMethod(Method method, Object instance) {
private static Class<?> getClass(String fqcn) {
try {
return (T) method.invoke(instance);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException(String.format("Failed to invoke method `%s`", method), e);
return RefasterIntrospection.class.getClassLoader().loadClass(fqcn);
} catch (ClassNotFoundException e) {
throw new IllegalStateException(String.format("Failed to load class `%s`", fqcn), e);
}
}

Expand All @@ -340,11 +339,12 @@ private static Method getMethod(Class<?> clazz, String methodName) {
}
}

private static Class<?> getClass(String fqcn) {
@SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"})
private static <T> T invokeMethod(Method method, Object instance) {
try {
return RefasterIntrospection.class.getClassLoader().loadClass(fqcn);
} catch (ClassNotFoundException e) {
throw new IllegalStateException(String.format("Failed to load class `%s`", fqcn), e);
return (T) method.invoke(instance);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException(String.format("Failed to invoke method `%s`", method), e);
}
}
}
Expand Down

0 comments on commit 67127ae

Please sign in to comment.