/** Get the return type of the method. @return Returns null for a loosely typed return value, Void.TYPE for a void return type, or the Class of the type. */ /* Note: bshmethod needs to re-evaluate the method return type here. This is broken. */ public Class<?> getReturnType() { if (null == this.javaMethod) return creturnType; return this.javaMethod.getReturnType(); }
/** Retrieve a method type from return type a parameter type signatures. * @return method type */ public MethodType methodType() { return MethodType.methodType(getReturnType(), getParameterTypes()); }
/** Retrieve a bytecode descriptor representation of the return type. * @return the bytecode type descriptor */ public String getReturnTypeDescriptor() { return BSHType.getTypeDescriptor(getReturnType()); }
/** {@inheritDoc} */ @Override public int hashCode() { return getClass().hashCode() ^ getName().hashCode() ^ getDeclaringClass().hashCode() ^ getParameterCount() ^ getReturnType().hashCode() ^ getModifiers() ^ Stream.of(getParameterTypes()) .map(t -> null == t ? 39 : t.hashCode()) .reduce(75, (a, b) -> a ^ b).intValue(); } }
BshMethod( Invocable method, Object object ) { this( method.getName(), method.getReturnType(), null/*paramNames*/, method.getParameterTypes(), null/*paramModifiers*/, null/*method.block*/, null/*declaringNameSpace*/, null/*modifiers*/ ); this.javaMethod = method; this.javaObject = object; }
/** Abstraction to cleanly apply the primitive result wrapping. * @param base represents the base object instance. * @param pars parameter arguments * @return invocation result * @throws InvocationTargetException wrapped target exceptions */ public synchronized Object invoke(Object base, Object... pars) throws InvocationTargetException { if (null == pars) pars = Reflect.ZERO_ARGS; try { return Primitive.wrap( invokeTarget(base, pars), getReturnType()); } catch (Throwable ite) { throw new InvocationTargetException(ite); } }
public Class<?> getType() { if ( null != field ) return field.getReturnType(); if ( null != var ) return var.getType(); try { return Types.getType(getValue()); } catch ( UtilEvalError e ) { return null; } }
name, false/* onlyStatic */); if (field != null) var = this.createVariable(name, field.getReturnType(), new LHS(object, field)); else if (this.isClass) { name, true/* onlyStatic */); if (field != null) { var = this.createVariable(name, field.getReturnType(), new LHS(field)); this.variables.put(name, var);
/** {@inheritDoc} */ @Override public boolean equals(Object o) { if (o == null) return false; if (this == o) return true; if (this.getClass() != o.getClass()) return false; Invocable member = (Invocable) o; if (!getName().equals(member.getName()) || getDeclaringClass() != member.getDeclaringClass() || getParameterCount() != member.getParameterCount() || getReturnType() != member.getReturnType() || getModifiers() != member.getModifiers()) return false; for (int i = 0; i < getParameterCount(); i++) if (getParameterTypes()[i] != member.getParameterTypes()[i]) return false; return true; }