Esempio n. 1
0
  public static Function getFunction(Scriptable obj, String functionName) {
    Object x = ScriptableObject.getProperty(obj, functionName);
    if (x == Scriptable.NOT_FOUND) {
      // This method used to swallow the exception from calling
      // an undefined method. People have come to depend on this
      // somewhat dubious behavior. It allows people to avoid
      // implementing listener methods that they don't care about,
      // for instance.
      return null;
    }
    if (!(x instanceof Function)) throw ScriptRuntime.notFunctionError(x, functionName);

    return (Function) x;
  }