/** Gets the method. * @param name the name * @param sig the sig * @return the method * @throws UtilEvalError the util eval error * @see #getMethod(String, Class [], boolean) * @see #getMethod(String, Class []) */ public BshMethod getMethod(final String name, final Class<?>[] sig) throws UtilEvalError { return this.getMethod(name, sig, false/* declaredOnly */); }
/** This is the invocation handler for the dynamic proxy. <p> Notes: Inner class for the invocation handler seems to shield this unavailable interface from JDK1.2 VM... I don't understand this. JThis works just fine even if those classes aren't there (doesn't it?) This class shouldn't be loaded if an XThis isn't instantiated in NameSpace.java, should it? */ class Handler implements InvocationHandler, java.io.Serializable { public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable { try { return invokeImpl( proxy, method, args ); } catch ( TargetError te ) { // Unwrap target exception. If the interface declares that // it throws the ex it will be delivered. If not it will be // wrapped in an UndeclaredThrowable // This isn't simple because unwrapping this loses all context info. // So rewrap is better than unwrap. - fschmidt Throwable t = te.getTarget(); Class<? extends Throwable> c = t.getClass(); String msg = t.getMessage(); try {
/** see #getMethod( String, Class [], boolean ) see #getMethod( String, Class [] ) */ public BshMethod getMethod( String name, Class [] sig ) throws UtilEvalError { return getMethod( name, sig, false/*declaredOnly*/ ); }
public static BshMethod getMethod(NameSpace ns, String name, Class<?>[] sig) { if (null == ns) return null; try { return ns.getMethod(name, sig, true); } catch (Exception e) { return null; } }
public BshMethod getMethod( String name, Class [] sig, boolean declaredOnly ) throws UtilEvalError { return super.getMethod( name, sig, declaredOnly ); }
private Function getFunction0(NameSpace bshns, String name, Class[] argTypes) { try { final BshMethod m = bshns.getMethod(name, argTypes != null ? argTypes : new Class[0], false); return m != null ? new BSHFunction(m) : null; } catch (UtilEvalError ex) { throw UiException.Aide.wrap(ex); } }
public PreparsedScript(final String source, final ClassLoader classLoader) throws EvalError { final ClassManagerImpl classManager = new ClassManagerImpl(); classManager.setClassLoader(classLoader); final NameSpace nameSpace = new NameSpace(classManager, "global"); _interpreter = new Interpreter(new StringReader(""), System.out, System.err, false, nameSpace, null, null); try { final This callable = (This) _interpreter.eval("__execute() { " + source + "\n" + "}\n" + "return this;"); _method = callable.getNameSpace().getMethod("__execute", new Class[0], false); } catch (final UtilEvalError e) { throw new IllegalStateException(e); } }
public PreparsedScript(final String source, final ClassLoader classLoader) throws EvalError { final ClassManagerImpl classManager = new ClassManagerImpl(); classManager.setClassLoader(classLoader); final NameSpace nameSpace = new NameSpace("global", classManager); _interpreter = new Interpreter(new StringReader(""), System.out, System.err, false, nameSpace, null, null); try { final This callable = (This) _interpreter.eval("__execute() { " + source + "\n" + "}\n" + "return this;"); _method = callable.getNameSpace().getMethod("__execute", Reflect.ZERO_TYPES, false); } catch (final UtilEvalError e) { throw new IllegalStateException(e); } }
return this.parent.getMethod(name, sig); return method;
return parent.getMethod( name, sig );
BshMethod constructor = instanceNameSpace.getMethod(Types.getBaseName(className), Types.getTypes(args), true/*declaredOnly*/);
final BshMethod meth = this.getMethod(name, argTypes);
/** Get a property from a scripted object or Primitive.VOID if no such * property exists. * @param propName the prop name * @param interp the interp * @return the property value * @throws UtilEvalError the util eval error */ Object getPropertyValue(final String propName, final Interpreter interp) throws UtilEvalError { String accessorName = Reflect.accessorName(Reflect.GET_PREFIX, propName); final Class<?>[] classArray = Reflect.ZERO_TYPES; BshMethod m = this.getMethod(accessorName, classArray); try { if (m != null) return m.invoke((Object[]) null, interp); accessorName = Reflect.accessorName(Reflect.IS_PREFIX, propName); m = this.getMethod(accessorName, classArray); if (m != null && m.getReturnType() == Boolean.TYPE) return m.invoke((Object[]) null, interp); return Primitive.VOID; } catch (final EvalError ee) { throw new UtilEvalError("'This' property accessor threw exception: " + ee.getMessage(), ee); } }
/** If a writable property exists for the given name, set it and return * true, otherwise do nothing and return false. * @param propName the prop name * @param value the value * @param interp the interp * @return true, if successful * @throws UtilEvalError the util eval error */ boolean attemptSetPropertyValue(final String propName, final Object value, final Interpreter interp) throws UtilEvalError { final String accessorName = Reflect.accessorName(Reflect.SET_PREFIX, propName); Object val = Primitive.unwrap(value); final Class<?>[] classArray = new Class<?>[] { val == null ? null : val.getClass()}; final BshMethod m = this.getMethod(accessorName, classArray); if (m != null) try { this.invokeMethod(accessorName, new Object[] {value}, interp); // m.invoke(new Object[] {value}, interp); return true; } catch (final EvalError ee) { throw new UtilEvalError( "'This' property accessor threw exception: " + ee.getMessage(), ee); } return false; }
BshMethod meth = getMethod( name, argTypes );
try { BshMethod constructor = instanceNameSpace.getMethod(constructorName, sig, true/*declaredOnly*/);