jdk.nashorn.internal.runtime.ErrorManager Java Examples

The following examples show how to use jdk.nashorn.internal.runtime.ErrorManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompilerTest.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
@BeforeClass
public void setupTest() {
    final Options options = new Options("nashorn");
    options.set("anon.functions", true);
    options.set("compile.only", true);
    options.set("print.ast", true);
    options.set("print.parse", true);
    options.set("scripting", true);
    options.set("const.as.var", true);
    options.set("verify.code", true);

    final ErrorManager errors = new ErrorManager() {
        @Override
        public void error(final String msg) {
            log(msg);
        }
    };

    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);
    this.context = new Context(options, errors, pw, pw, Thread.currentThread().getContextClassLoader());
    this.global = context.createGlobal();
}
 
Example #2
Source File: Parser.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 * @param lineOffset line offset to start counting lines from
 * @param log debug logger if one is needed
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict, final int lineOffset, final DebugLogger log) {
    super(source, errors, strict, lineOffset);
    this.env = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }

    this.log = log == null ? DebugLogger.DISABLED_LOGGER : log;
}
 
Example #3
Source File: Parser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 * @param lineOffset line offset to start counting lines from
 * @param log debug logger if one is needed
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict, final int lineOffset, final DebugLogger log) {
    super(source, errors, strict, lineOffset);
    this.env = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }

    this.log = log == null ? DebugLogger.DISABLED_LOGGER : log;
}
 
Example #4
Source File: Parser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 * @param lineOffset line offset to start counting lines from
 * @param log debug logger if one is needed
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict, final int lineOffset, final DebugLogger log) {
    super(source, errors, strict, lineOffset);
    this.env = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }

    this.log = log == null ? DebugLogger.DISABLED_LOGGER : log;
}
 
Example #5
Source File: ContextTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void compileErrorTest() {
    final Options options = new Options("");
    final ErrorManager errors = new ErrorManager();
    final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
    final Global oldGlobal = Context.getGlobal();
    Context.setGlobal(cx.createGlobal());
    try {
        final ScriptFunction script = cx.compileScript(sourceFor("<evalCompileErrorTest>", "*/"), Context.getGlobal());
        if (script != null) {
            fail("Invalid script compiled without errors");
        }
        if (errors.getNumberOfErrors() != 1) {
            fail("Wrong number of errors: " + errors.getNumberOfErrors());
        }
    } finally {
        Context.setGlobal(oldGlobal);
    }
}
 
Example #6
Source File: ContextTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void evalTest() {
    final Options options = new Options("");
    final ErrorManager errors = new ErrorManager();
    final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
    final Global oldGlobal = Context.getGlobal();
    Context.setGlobal(cx.createGlobal());
    try {
        String code = "22 + 10";
        assertTrue(32.0 == ((Number)(eval(cx, "<evalTest>", code))).doubleValue());

        code = "obj = { js: 'nashorn' }; obj.js";
        assertEquals(eval(cx, "<evalTest2>", code), "nashorn");
    } finally {
        Context.setGlobal(oldGlobal);
    }
}
 
Example #7
Source File: ContextTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void compileErrorTest() {
    final Options options = new Options("");
    final ErrorManager errors = new ErrorManager();
    final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
    final Global oldGlobal = Context.getGlobal();
    Context.setGlobal(cx.createGlobal());
    try {
        final ScriptFunction script = cx.compileScript(sourceFor("<evalCompileErrorTest>", "*/"), Context.getGlobal());
        if (script != null) {
            fail("Invalid script compiled without errors");
        }
        if (errors.getNumberOfErrors() != 1) {
            fail("Wrong number of errors: " + errors.getNumberOfErrors());
        }
    } finally {
        Context.setGlobal(oldGlobal);
    }
}
 
Example #8
Source File: CompilerTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@BeforeClass
public void setupTest() {
    final Options options = new Options("nashorn");
    options.set("anon.functions", true);
    options.set("compile.only", true);
    options.set("print.ast", true);
    options.set("print.parse", true);
    options.set("scripting", true);

    final ErrorManager errors = new ErrorManager() {
        @Override
        public void error(final String msg) {
            log(msg);
        }
    };

    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);
    this.context = new Context(options, errors, pw, pw, Thread.currentThread().getContextClassLoader());
    this.global = context.createGlobal();
}
 
Example #9
Source File: ContextTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void evalTest() {
    final Options options = new Options("");
    final ErrorManager errors = new ErrorManager();
    final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
    final Global oldGlobal = Context.getGlobal();
    Context.setGlobal(cx.createGlobal());
    try {
        String code = "22 + 10";
        assertTrue(32.0 == ((Number)(eval(cx, "<evalTest>", code))).doubleValue());

        code = "obj = { js: 'nashorn' }; obj.js";
        assertEquals(eval(cx, "<evalTest2>", code), "nashorn");
    } finally {
        Context.setGlobal(oldGlobal);
    }
}
 
Example #10
Source File: CompilerTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@BeforeClass
public void setupTest() {
    final Options options = new Options("nashorn");
    options.set("compile.only", true);
    options.set("print.ast", true);
    options.set("print.parse", true);
    options.set("scripting", true);
    options.set("const.as.var", true);
    options.set("verify.code", true);

    final ErrorManager errors = new ErrorManager() {
        @Override
        public void error(final String msg) {
            log(msg);
        }
    };

    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);
    this.context = new Context(options, errors, pw, pw, Thread.currentThread().getContextClassLoader());
    this.global = context.createGlobal();
}
 
Example #11
Source File: CompilerTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@BeforeClass
public void setupTest() {
    final Options options = new Options("nashorn");
    options.set("anon.functions", true);
    options.set("compile.only", true);
    options.set("print.ast", true);
    options.set("print.parse", true);
    options.set("scripting", true);
    options.set("const.as.var", true);
    options.set("verify.code", true);

    final ErrorManager errors = new ErrorManager() {
        @Override
        public void error(final String msg) {
            log(msg);
        }
    };

    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);
    this.context = new Context(options, errors, pw, pw, Thread.currentThread().getContextClassLoader());
    this.global = context.createGlobal();
}
 
Example #12
Source File: Parser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 * @param lineOffset line offset to start counting lines from
 * @param log debug logger if one is needed
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict, final int lineOffset, final DebugLogger log) {
    super(source, errors, strict, lineOffset);
    this.env = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }

    this.log = log == null ? DebugLogger.DISABLED_LOGGER : log;
}
 
Example #13
Source File: Parser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 * @param lineOffset line offset to start counting lines from
 * @param log debug logger if one is needed
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict, final int lineOffset, final DebugLogger log) {
    super(source, errors, strict, lineOffset);
    this.env = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }

    this.log = log == null ? DebugLogger.DISABLED_LOGGER : log;
}
 
Example #14
Source File: ContextTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void evalTest() {
    final Options options = new Options("");
    final ErrorManager errors = new ErrorManager();
    final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
    final Global oldGlobal = Context.getGlobal();
    Context.setGlobal(cx.createGlobal());
    try {
        String code = "22 + 10";
        assertTrue(32.0 == ((Number)(eval(cx, "<evalTest>", code))).doubleValue());

        code = "obj = { js: 'nashorn' }; obj.js";
        assertEquals(eval(cx, "<evalTest2>", code), "nashorn");
    } finally {
        Context.setGlobal(oldGlobal);
    }
}
 
Example #15
Source File: JSONParser.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
ParserException error(final String message, final int start, final int length) throws ParserException {
    final long token     = Token.toDesc(STRING, start, length);
    final int  pos       = Token.descPosition(token);
    final Source src     = Source.sourceFor("<json>", source);
    final int  lineNum   = src.getLine(pos);
    final int  columnNum = src.getColumn(pos);
    final String formatted = ErrorManager.format(message, src, lineNum, columnNum, token);
    return new ParserException(JSErrorType.SYNTAX_ERROR, formatted, src, lineNum, columnNum, token);
}
 
Example #16
Source File: AbstractParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Report an error.
 *
 * @param errorType  The error type
 * @param message    Error message.
 * @return ParserException upon failure. Caller should throw and not ignore
 */
protected final ParserException error(final JSErrorType errorType, final String message) {
    // TODO - column needs to account for tabs.
    final int position = Token.descPosition(token);
    final int column = position - linePosition;
    final String formatted = ErrorManager.format(message, source, line, column, token);
    return new ParserException(errorType, formatted, source, line, column, token);
}
 
Example #17
Source File: SharedContextEvaluator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * SharedContextEvaluator constructor
 * @param args initial script arguments to create shared context
 */
public SharedContextEvaluator(final String[] args) {
    this.ctxOut = new DelegatingOutputStream(System.out);
    this.ctxErr = new DelegatingOutputStream(System.err);
    final PrintWriter wout = new PrintWriter(ctxOut, true);
    final PrintWriter werr = new PrintWriter(ctxErr, true);
    final Options options = new Options("nashorn", werr);
    options.process(args);
    final ErrorManager errors = new ErrorManager(werr);
    this.context = new Context(options, errors, wout, werr, Thread.currentThread().getContextClassLoader());
}
 
Example #18
Source File: ParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeClass
public void setupTest() {
    final Options options = new Options("nashorn");
    options.set("parse.only", true);
    options.set("scripting", true);
    options.set("const.as.var", true);

    final ErrorManager errors = new ErrorManager();
    this.context = new Context(options, errors, Thread.currentThread().getContextClassLoader());
}
 
Example #19
Source File: AbstractParser.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param source     Source to parse.
 * @param errors     Error reporting manager.
 * @param strict     True if we are in strict mode
 * @param lineOffset Offset from which lines should be counted
 */
protected AbstractParser(final Source source, final ErrorManager errors, final boolean strict, final int lineOffset) {
    this.source       = source;
    this.errors       = errors;
    this.k            = -1;
    this.token        = Token.toDesc(EOL, 0, 1);
    this.type         = EOL;
    this.last         = EOL;
    this.isStrictMode = strict;
    this.lineOffset   = lineOffset;
}
 
Example #20
Source File: AssignSymbols.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private void throwParserException(final String message, final Node origin) {
    if (origin == null) {
        throw new ParserException(message);
    }
    final Source source = compiler.getSource();
    final long token = origin.getToken();
    final int line = source.getLine(origin.getStart());
    final int column = source.getColumn(origin.getStart());
    final String formatted = ErrorManager.format(message, source, line, column, token);
    throw new ParserException(JSErrorType.SYNTAX_ERROR, formatted, source, line, column, token);
}
 
Example #21
Source File: NashornScriptEngine.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
NashornScriptEngine(final NashornScriptEngineFactory factory, final String[] args, final ClassLoader appLoader) {
    this.factory = factory;
    final Options options = new Options("nashorn");
    options.process(args);

    // throw ParseException on first error from script
    final ErrorManager errMgr = new Context.ThrowErrorManager();
    // create new Nashorn Context
    this.nashornContext = AccessController.doPrivileged(new PrivilegedAction<Context>() {
        @Override
        public Context run() {
            try {
                return new Context(options, errMgr, appLoader);
            } catch (final RuntimeException e) {
                if (Context.DEBUG) {
                    e.printStackTrace();
                }
                throw e;
            }
        }
    }, CREATE_CONTEXT_ACC_CTXT);

    // cache this option that is used often
    this._global_per_engine = nashornContext.getEnv()._global_per_engine;

    // create new global object
    this.global = createNashornGlobal(context);
    // set the default ENGINE_SCOPE object for the default context
    context.setBindings(new ScriptObjectMirror(global, global), ScriptContext.ENGINE_SCOPE);
}
 
Example #22
Source File: Compiler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private Compiler(
        final Context context,
        final CodeInstaller installer,
        final Source source,
        final ErrorManager errors,
        final boolean isStrict,
        final boolean isOnDemand,
        final RecompilableScriptFunctionData compiledFunction,
        final TypeMap types,
        final Map<Integer, Type> invalidatedProgramPoints,
        final Object typeInformationFile,
        final int[] continuationEntryPoints,
        final ScriptObject runtimeScope) {
    this.context                  = context;
    this.env                      = context.getEnv();
    this.installer                = installer;
    this.constantData             = new ConstantData();
    this.compileUnits             = CompileUnit.createCompileUnitSet();
    this.bytecode                 = new LinkedHashMap<>();
    this.log                      = initLogger(context);
    this.source                   = source;
    this.errors                   = errors;
    this.sourceName               = FunctionNode.getSourceName(source);
    this.onDemand                 = isOnDemand;
    this.compiledFunction         = compiledFunction;
    this.types                    = types;
    this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new HashMap<Integer, Type>() : invalidatedProgramPoints;
    this.typeInformationFile      = typeInformationFile;
    this.continuationEntryPoints  = continuationEntryPoints == null ? null: continuationEntryPoints.clone();
    this.typeEvaluator            = new TypeEvaluator(this, runtimeScope);
    this.firstCompileUnitName     = firstCompileUnitName();
    this.strict                   = isStrict;

    this.optimistic = env._optimistic_types;
}
 
Example #23
Source File: JSONParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
ParserException error(final String message, final int start, final int length) throws ParserException {
    final long token     = Token.toDesc(STRING, start, length);
    final int  pos       = Token.descPosition(token);
    final Source src     = Source.sourceFor("<json>", source);
    final int  lineNum   = src.getLine(pos);
    final int  columnNum = src.getColumn(pos);
    final String formatted = ErrorManager.format(message, src, lineNum, columnNum, token);
    return new ParserException(JSErrorType.SYNTAX_ERROR, formatted, src, lineNum, columnNum, token);
}
 
Example #24
Source File: AbstractParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Report an error.
 *
 * @param errorType  The error type
 * @param message    Error message.
 * @return ParserException upon failure. Caller should throw and not ignore
 */
protected final ParserException error(final JSErrorType errorType, final String message) {
    // TODO - column needs to account for tabs.
    final int position = Token.descPosition(token);
    final int column = position - linePosition;
    final String formatted = ErrorManager.format(message, source, line, column, token);
    return new ParserException(errorType, formatted, source, line, column, token);
}
 
Example #25
Source File: AbstractParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param source     Source to parse.
 * @param errors     Error reporting manager.
 * @param strict     True if we are in strict mode
 * @param lineOffset Offset from which lines should be counted
 */
protected AbstractParser(final Source source, final ErrorManager errors, final boolean strict, final int lineOffset) {
    this.source       = source;
    this.errors       = errors;
    this.k            = -1;
    this.token        = Token.toDesc(EOL, 0, 1);
    this.type         = EOL;
    this.last         = EOL;
    this.isStrictMode = strict;
    this.lineOffset   = lineOffset;
}
 
Example #26
Source File: Compiler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private Compiler(
        final Context context,
        final CodeInstaller installer,
        final Source source,
        final ErrorManager errors,
        final boolean isStrict,
        final boolean isOnDemand,
        final RecompilableScriptFunctionData compiledFunction,
        final TypeMap types,
        final Map<Integer, Type> invalidatedProgramPoints,
        final Object typeInformationFile,
        final int[] continuationEntryPoints,
        final ScriptObject runtimeScope) {
    this.context                  = context;
    this.env                      = context.getEnv();
    this.installer                = installer;
    this.constantData             = new ConstantData();
    this.compileUnits             = CompileUnit.createCompileUnitSet();
    this.bytecode                 = new LinkedHashMap<>();
    this.log                      = initLogger(context);
    this.source                   = source;
    this.errors                   = errors;
    this.sourceName               = FunctionNode.getSourceName(source);
    this.onDemand                 = isOnDemand;
    this.compiledFunction         = compiledFunction;
    this.types                    = types;
    this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new HashMap<Integer, Type>() : invalidatedProgramPoints;
    this.typeInformationFile      = typeInformationFile;
    this.continuationEntryPoints  = continuationEntryPoints == null ? null: continuationEntryPoints.clone();
    this.typeEvaluator            = new TypeEvaluator(this, runtimeScope);
    this.firstCompileUnitName     = firstCompileUnitName();
    this.strict                   = isStrict;

    this.optimistic = env._optimistic_types;
}
 
Example #27
Source File: ParserTest.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@BeforeClass
public void setupTest() {
    final Options options = new Options("nashorn");
    options.set("anon.functions", true);
    options.set("parse.only", true);
    options.set("scripting", true);
    options.set("const.as.var", true);

    final ErrorManager errors = new ErrorManager();
    this.context = new Context(options, errors, Thread.currentThread().getContextClassLoader());
}
 
Example #28
Source File: AbstractParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a parser.
 *
 * @param source     Source to parse.
 * @param errors     Error reporting manager.
 * @param strict     True if we are in strict mode
 * @param lineOffset Offset from which lines should be counted
 */
protected AbstractParser(final Source source, final ErrorManager errors, final boolean strict, final int lineOffset) {
    this.source       = source;
    this.errors       = errors;
    this.k            = -1;
    this.token        = Token.toDesc(EOL, 0, 1);
    this.type         = EOL;
    this.last         = EOL;
    this.isStrictMode = strict;
    this.lineOffset   = lineOffset;
}
 
Example #29
Source File: ParserTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeClass
public void setupTest() {
    final Options options = new Options("nashorn");
    options.set("anon.functions", true);
    options.set("parse.only", true);
    options.set("scripting", true);
    options.set("const.as.var", true);

    final ErrorManager errors = new ErrorManager();
    this.context = new Context(options, errors, Thread.currentThread().getContextClassLoader());
}
 
Example #30
Source File: ParserTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@BeforeClass
public void setupTest() {
    final Options options = new Options("nashorn");
    options.set("anon.functions", true);
    options.set("parse.only", true);
    options.set("scripting", true);
    options.set("const.as.var", true);

    final ErrorManager errors = new ErrorManager();
    this.context = new Context(options, errors, Thread.currentThread().getContextClassLoader());
}