*
* TODO: make the custom class loader work (at not loading all the Java classes).
*/
@BeforeClass
public static void messWithClassLoader() {
ContextFactory.initGlobal(new ContextFactory() {
@Override
protected Context makeContext() {
Context cx = super.makeContext();
cx.setWrapFactory(new WrapFactory() {
@Override
public Object wrap(Context cx, Scriptable scope, Object obj, Class staticType) {
return super.wrap(cx, scope, obj, staticType);
}
@Override
public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) {
return super.wrapNewObject(cx, scope, obj);
}
@Override
public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) {
return new SandboxNativeJavaObject(scope, javaObject, staticType);
}
});
return cx;
}
});
ContextFactory factory = ContextFactory.getGlobal();
factory.initApplicationClassLoader(new SandboxClassLoader(TurtleSpecSection2_1Test.class.getClassLoader()));
}