From 4ca5efc1dce87da54543e12de60deaa7cefc8b83 Mon Sep 17 00:00:00 2001 From: Fried Hoeben Date: Sat, 25 Apr 2015 08:08:11 +0200 Subject: [PATCH] Don't use reflection on each 'around invocation' --- src/fitnesse/slim/MethodExecutor.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/fitnesse/slim/MethodExecutor.java b/src/fitnesse/slim/MethodExecutor.java index fa299bd133..7de1e31100 100644 --- a/src/fitnesse/slim/MethodExecutor.java +++ b/src/fitnesse/slim/MethodExecutor.java @@ -8,8 +8,14 @@ import fitnesse.slim.fixtureInteraction.InteractionAwareFixture; public abstract class MethodExecutor { - public MethodExecutor() { - super(); + private static final Method AROUND_METHOD; + + static { + try { + AROUND_METHOD = InteractionAwareFixture.class.getMethod("aroundSlimInvoke", FixtureInteraction.class, Method.class, Object[].class); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } } public abstract MethodExecutionResult execute(String instanceName, String methodName, Object[] args) throws Throwable; @@ -45,10 +51,8 @@ protected Object callMethod(Object instance, Method method, Object[] convertedAr Object result; if (instance instanceof InteractionAwareFixture) { // invoke via interaction, so it can also do its thing on the aroundMethod invocation - Class clazz = instance.getClass(); - Method aroundMethod = clazz.getMethod("aroundSlimInvoke", FixtureInteraction.class, Method.class, Object[].class); Object[] args = { interaction, method, convertedArgs }; - result = interaction.methodInvoke(aroundMethod, instance, args); + result = interaction.methodInvoke(AROUND_METHOD, instance, args); } else { result = interaction.methodInvoke(method, instance, convertedArgs); }