/** * Initialize the context. */ private ScriptableObject createContext(final ScriptableObject initialScope) { final Context context = getContext(); context.setOptimizationLevel(-1); // TODO redirect errors from System.err to LOG.error() context.setErrorReporter(new ToolErrorReporter(false)); context.setLanguageVersion(Context.VERSION_1_8); InputStream script = null; final ScriptableObject scriptCommon = (ScriptableObject) context.initStandardObjects(initialScope); try { script = getClass().getResourceAsStream("commons.js"); context.evaluateReader(scriptCommon, new InputStreamReader(script), "commons.js", 1, null); } catch (final IOException e) { throw new RuntimeException("Problem while evaluationg commons script.", e); } finally { IOUtils.closeQuietly(script); } return scriptCommon; }
@Override protected void onContextCreated(Context cx) { cx.setLanguageVersion(languageVersion); cx.setOptimizationLevel(optimizationLevel); if (errorReporter != null) { cx.setErrorReporter(errorReporter); } cx.setGeneratingDebug(generatingDebug); super.onContextCreated(cx); }
protected Context enterContext() { Context context = Context.enter(); context.setOptimizationLevel(-1); // TODO redirect errors from System.err to LOG.error() context.setErrorReporter(new ToolErrorReporter(false)); context.setLanguageVersion(Context.VERSION_1_8); return context; }
@Override protected void onContextCreated(Context cx) { cx.setLanguageVersion(languageVersion); cx.setOptimizationLevel(optimizationLevel); if (errorReporter != null) { cx.setErrorReporter(errorReporter); } cx.setGeneratingDebug(generatingDebug); super.onContextCreated(cx); }
/** * Initialize the context. */ private ScriptableObject createContext(final ScriptableObject initialScope) { final Context context = getContext(); context.setOptimizationLevel(-1); // TODO redirect errors from System.err to LOG.error() context.setErrorReporter(new ToolErrorReporter(false)); context.setLanguageVersion(Context.VERSION_1_8); InputStream script = null; final ScriptableObject scriptCommon = (ScriptableObject) context.initStandardObjects(initialScope); try { script = new AutoCloseInputStream(getClass().getResourceAsStream("commons.js")); context.evaluateReader(scriptCommon, new InputStreamReader(script), "commons.js", 1, null); } catch (final IOException e) { throw new RuntimeException("Problem while evaluationg commons script.", e); } finally { IOUtils.closeQuietly(script); } return scriptCommon; }
String resultString = ""; ErrorReporter savedErrorReporter = cx.getErrorReporter(); cx.setErrorReporter(new ToolErrorReporter(false, this.getErr())); try { testCount++; this.setOut(savedOut); this.setErr(savedErr); cx.setErrorReporter(savedErrorReporter); resultString += err.toString() + out.toString();
String resultString = ""; ErrorReporter savedErrorReporter = cx.getErrorReporter(); cx.setErrorReporter(new ToolErrorReporter(false, this.getErr())); try { testCount++; this.setOut(savedOut); this.setErr(savedErr); cx.setErrorReporter(savedErrorReporter); resultString += err.toString() + out.toString();
private void enableDebugger(HttpServletRequest request, HttpServletResponse response, String moduleOrCode, Context context) { Context rhinoContext = (Context) context; ErrorReporter reporter = new RhinoJavascriptDebugInvocationErrorReporter(); rhinoContext.setErrorReporter(reporter); String userId = UserFacade.getName(request); logger.debug("creating DebugModel ..."); DebugModel debugModel = DebugManager.getDebugModel(userId); if (debugModel == null) { debugModel = DebugModelFacade.createDebugModel(userId, new RhinoJavascriptDebugController(userId)); } logger.debug("creating JavascriptDebugger ..."); RhinoJavascriptDebugger debugger = new RhinoJavascriptDebugger(debugModel, request); rhinoContext.setDebugger(debugger, JAVA_SCRIPT_DEBUGGER); logger.debug("created JavascriptDebugger"); RhinoJavascriptDebugSender.sendCurrentSessions(userId, debugModel); rhinoContext.setGeneratingDebug(true); rhinoContext.setOptimizationLevel(-1); }
@Override protected void init() { super.init(); Context context = Context.enter(); context.setErrorReporter(new RhinoErrorReporter(false, console.out())); context.setWrapFactory(new RhinoCustomWrapFactory()); }
cx.setErrorReporter(reporter); try {
context.setGeneratingDebug(true); context.setCompileFunctionsWithDynamicScope(true); context.setErrorReporter(new JSErrorReporter());