Skip to content

Instantly share code, notes, and snippets.

@jbeard4
Created May 24, 2012 13:42
Show Gist options
  • Save jbeard4/2781612 to your computer and use it in GitHub Desktop.
Save jbeard4/2781612 to your computer and use it in GitHub Desktop.
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ScriptableObject;
import test.Reduced;
class TestReduced {
public static void main(String[] args){
Reduced reduced = new Reduced();
Scriptable o = (Scriptable) reduced.getObj();
System.out.println("js object:");
System.out.println(o);
Scriptable scope = o.getParentScope();
System.out.println("scope:");
System.out.println(scope);
Function getXFn = (Function) ScriptableObject.getProperty(o,"getX");
System.out.println("getX function:");
System.out.println(getXFn);
//this will always be null.
//how do we get the context?
Context context = Context.getCurrentContext();
System.out.println("context:");
System.out.println(context);
Object[] getXFnArgs = {};
getXFn.call(context,scope,o,getXFnArgs);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment