private final Object invokeTarget(EvaluationContext ctx, Object target, Object[] paramValues) throws ELException { if (target instanceof MethodExpression) { MethodExpression me = (MethodExpression) target; return me.invoke(ctx.getELContext(), paramValues); } else if (target == null) { throw new MethodNotFoundException("Identity '" + this.image + "' was null and was unable to invoke"); } else { throw new ELException( "Identity '" + this.image + "' does not reference a MethodExpression instance, returned type: " + target.getClass().getName()); } }
/** * Returns a method based on the criteria * @param base the object that owns the method * @param property the name of the method * @param paramTypes the parameter types to use * @return the method specified * @throws MethodNotFoundException */ public static Method getMethod(Object base, Object property, Class[] paramTypes) throws MethodNotFoundException { if (base == null || property == null) { throw new MethodNotFoundException(MessageFactory.get( "error.method.notfound", base, property, paramString(paramTypes))); } String methodName = (property instanceof String) ? (String) property : property.toString(); Method method = null; try { method = base.getClass().getMethod(methodName, paramTypes); } catch (NoSuchMethodException nsme) { throw new MethodNotFoundException(MessageFactory.get( "error.method.notfound", base, property, paramString(paramTypes))); } return method; }
/** * ラムダ式のテスト - EL2.xでは非さぽーとのため失敗する */ @Test(expected=ExpressionEvaluationException.class) public void testEvaluate_lambda() { String expression = "sum=0;list.stream().forEach(x->(sum=sum+x));sum"; Map<String, Object> vars = new HashMap<>(); vars.put("list", Arrays.asList(1, 2, 3, 4, 5, 6)); try { el.evaluate(expression, vars); fail(); } catch(Exception e) { assertThat(e, is(instanceOf(ExpressionEvaluationException.class))); assertThat(e.getCause(), is(instanceOf(MethodNotFoundException.class))); throw e; } }
public static Method findMethod(Object base, Object name, Object[] params) { Method r = null; if (base != null && name != null) { Class type = base.getClass(); String methodName = ELSupport.coerceToString(name); MethodCache m = methodCache.get(type); // if (m == null || type != m.getType()) { // m = new MethodCache(type); // methodCache.set(type, m); // } r = m.findMethod(methodName, params); if (r == null) { throw new MethodNotFoundException(MessageFactory.get( "error.method.notfound", base, name, paramString(paramTypes(params)))); } } else { throw new MethodNotFoundException(); } return r; }
/** * Returns a method based on the criteria * * @param base * the object that owns the method * @param property * the name of the method * @param paramTypes * the parameter types to use * @return the method specified * @throws MethodNotFoundException */ public static Method getMethod(Object base, Object property, Class[] paramTypes) throws MethodNotFoundException { if (base == null || property == null) { throw new MethodNotFoundException(MessageFactory.get( "error.method.notfound", base, property, paramString(paramTypes))); } String methodName = (property instanceof String) ? (String) property : property.toString(); Method method = null; try { method = base.getClass().getMethod(methodName, paramTypes); } catch (NoSuchMethodException nsme) { throw new MethodNotFoundException(MessageFactory.get( "error.method.notfound", base, property, paramString(paramTypes))); } return method; }
private final MethodExpression getMethodExpression(EvaluationContext ctx) throws ELException { Object obj = null; // case A: ValueExpression exists, getValue which must // be a MethodExpression VariableMapper varMapper = ctx.getVariableMapper(); ValueExpression ve = null; if (varMapper != null) { ve = varMapper.resolveVariable(this.image); if (ve != null) { obj = ve.getValue(ctx); } } // case B: evaluate the identity against the ELResolver, again, must be // a MethodExpression to be able to invoke if (ve == null) { ctx.setPropertyResolved(false); obj = ctx.getELResolver().getValue(ctx, null, this.image); } // finally provide helpful hints if (obj instanceof MethodExpression) { return (MethodExpression) obj; } else if (obj == null) { throw new MethodNotFoundException("Identity '" + this.image + "' was null and was unable to invoke"); } else { throw new ELException( "Identity '" + this.image + "' does not reference a MethodExpression instance, returned type: " + obj.getClass().getName()); } }
private final MethodExpression getMethodExpression(EvaluationContext ctx) throws ELException { Object obj = null; // case A: ValueExpression exists, getValue which must // be a MethodExpression VariableMapper varMapper = ctx.getVariableMapper(); ValueExpression ve = null; if (varMapper != null) { ve = varMapper.resolveVariable(this.image); if (ve != null) { obj = ve.getValue(ctx); } } // case B: evaluate the identity against the ELResolver, again, must be // a MethodExpression to be able to invoke if (ve == null) { ctx.setPropertyResolved(false); obj = ctx.getELResolver().getValue(ctx, null, this.image); } // finally provide helpful hints if (obj instanceof MethodExpression) { return (MethodExpression) obj; } else if (obj == null) { throw new MethodNotFoundException("Identity '" + this.image + "' was null and was unable to invoke"); } else { throw new ELException("Identity '" + this.image + "' does not reference a MethodExpression instance, returned type: " + obj.getClass().getName()); } }
@Override public Object invoke(final ELContext context, final Object base, final Object method, final Class<?>[] paramTypes, final Object[] params) { if (resolveType(base)) { if (isStrictMode) { throw new MethodNotFoundException(); } } return null; }
protected Method findMethodOrThrow(final String methodName, final Class<?>[] paramTypes, final Object[] params, final boolean staticOnly, final MethodDescriptor[] methodDescriptors) { final Method method = findMethod(methodName, paramTypes, params, staticOnly, methodDescriptors); if (method == null) { throw new MethodNotFoundException("Method " + methodName + "for bean class " + "not found or accessible"); } return method; }
protected Method findMethodOrThrow(final String methodName, final Class<?>[] paramTypes, final Object[] params, final boolean staticOnly, final Map<String, List<MethodDescriptor>> methodDescriptors) { final Method method = findMethod(methodName, paramTypes, params, staticOnly, methodDescriptors); if (method == null) { throw new MethodNotFoundException("Method " + methodName + " for bean class " + "not found or accessible"); } return method; }
protected Method findMethodOrThrow(final Class<?> klass, final String methodName, final Class<?>[] paramTypes, final Object[] params, final boolean staticOnly) { final Method method = findMethod(klass, methodName, paramTypes, params, staticOnly); if (method == null) { throw new MethodNotFoundException("Method " + methodName + "for class " + klass + " not found or accessible"); } return method; }
@Override public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) { if (method == null || RESTRICTED_METHODS.contains(method.toString())) { throw new MethodNotFoundException("Cannot find method '" + method + "' in " + base.getClass()); } return super.invoke(context, base, method, paramTypes, params); }
public JspMethodNotFoundException(String mark, MethodNotFoundException e) { super(mark + " " + e.getMessage(), e.getCause()); }
@Test(expected=MethodNotFoundException.class) public void testBug54370a() { ReflectionUtil.getMethod(BASE, "testA", new Class[] {null, String.class}, new Object[] {null, ""}); }
@Test(expected=MethodNotFoundException.class) public void testBug54370b() { ReflectionUtil.getMethod(BASE, "testB", new Class[] {null, String.class}, new Object[] {null, ""}); }
@Override public ExperimentCatResource create(ResourceType type) throws RegistryException { throw new MethodNotFoundException(); }
@Override public void remove(ResourceType type, Object name) throws RegistryException { throw new MethodNotFoundException(); }
@Override public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException { throw new MethodNotFoundException(); }