diff --git a/refaster-runner/src/main/java/tech/picnic/errorprone/refaster/runner/RefasterRuleSelector.java b/refaster-runner/src/main/java/tech/picnic/errorprone/refaster/runner/RefasterRuleSelector.java index 62da3099137..81e49e163fb 100644 --- a/refaster-runner/src/main/java/tech/picnic/errorprone/refaster/runner/RefasterRuleSelector.java +++ b/refaster-runner/src/main/java/tech/picnic/errorprone/refaster/runner/RefasterRuleSelector.java @@ -320,12 +320,11 @@ static ImmutableList getExpressions(UAnyOf tree) { return invokeMethod(METHOD_UANY_OF_EXPRESSIONS, tree); } - @SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"}) - private static 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); } } @@ -340,11 +339,12 @@ private static Method getMethod(Class clazz, String methodName) { } } - private static Class getClass(String fqcn) { + @SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"}) + private static 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); } } }