diff --git a/src/main/java/org/arl/fjage/param/ParameterMessageBehavior.java b/src/main/java/org/arl/fjage/param/ParameterMessageBehavior.java index 8b969eb7..bdc04dfa 100644 --- a/src/main/java/org/arl/fjage/param/ParameterMessageBehavior.java +++ b/src/main/java/org/arl/fjage/param/ParameterMessageBehavior.java @@ -379,8 +379,18 @@ private Object invokeCompatibleSetter(String name, int ndx, Object value) throws NoSuchMethodException nsme = null; try { return MethodUtils.invokeMethod(agent, name, ndx, value); - } catch (NoSuchMethodException ex) { - nsme = ex; + } catch (NoSuchMethodException ignored) { + // If MethodUtils.invokeMethod fails, we will try to invoke the method by + // getting the method and invoking it directly + Class[] parameterTypes = new Class[2]; + parameterTypes[0] = Integer.TYPE; + parameterTypes[1] = value.getClass(); + try { + Method m = agent.getClass().getMethod(name, parameterTypes); + return m.invoke(agent, ndx, value); + } catch (NoSuchMethodException ex) { + nsme = ex; + } } if (value instanceof Number) { Number nvalue = (Number) value;