From 67127aeebc67873505173428f2297c178d4a803e Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Tue, 27 Sep 2022 14:50:04 +0200 Subject: [PATCH] Reorder methods in `RefasterIntrospection` --- .../refaster/runner/RefasterRuleSelector.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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); } } }