Java Code Examples for jdk.nashorn.internal.runtime.options.Options#process()

The following examples show how to use jdk.nashorn.internal.runtime.options.Options#process() . 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: SharedContextEvaluator.java    From TencentKona-8 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 2
Source File: SharedContextEvaluator.java    From jdk8u60 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 3
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 4
Source File: SharedContextEvaluator.java    From openjdk-jdk8u-backup 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 5
Source File: ParserImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
ParserImpl(final String... args) throws IllegalArgumentException {
    Objects.requireNonNull(args);

    // handle the parser specific "--es6-module" option
    boolean seenModuleOption = false;
    for (int idx = 0; idx < args.length; idx++) {
        final String opt = args[idx];
        if (opt.equals("--es6-module")) {
            seenModuleOption = true;
            /*
             * Nashorn parser does not understand parser API specific
             * option. This option implies --language=es6. So, we change
             * the option to --language=es6. Note that if user specified
             * --language=es6 explicitly, that is okay. Nashorn tolerates
             * repeated options!
             */
            args[idx] = "--language=es6";
            break;
        }
    }
    this.moduleMode = seenModuleOption;

    // append "--parse-only to signal to the Nashorn that it
    // is being used in "parse only" mode.
    final String[] newArgs = Arrays.copyOf(args, args.length + 1, String[].class);
    newArgs[args.length] = "--parse-only";
    final Options options = new Options("nashorn");
    options.process(newArgs);
    this.env = new ScriptEnvironment(options,
            new PrintWriter(System.out), new PrintWriter(System.err));
}
 
Example 6
Source File: SharedContextEvaluator.java    From openjdk-jdk9 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 7
Source File: SharedContextEvaluator.java    From hottub 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 8
Source File: NashornScriptEngine.java    From openjdk-8-source 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 9
Source File: SharedContextEvaluator.java    From openjdk-8-source 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);
    PrintWriter wout = new PrintWriter(ctxOut, true);
    PrintWriter werr = new PrintWriter(ctxErr, true);
    Options options = new Options("nashorn", werr);
    options.process(args);
    ErrorManager errors = new ErrorManager(werr);
    this.context = new Context(options, errors, wout, werr, Thread.currentThread().getContextClassLoader());
}
 
Example 10
Source File: NashornScriptEngine.java    From openjdk-8 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 11
Source File: SharedContextEvaluator.java    From openjdk-8 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);
    PrintWriter wout = new PrintWriter(ctxOut, true);
    PrintWriter werr = new PrintWriter(ctxErr, true);
    Options options = new Options("nashorn", werr);
    options.process(args);
    ErrorManager errors = new ErrorManager(werr);
    this.context = new Context(options, errors, wout, werr, Thread.currentThread().getContextClassLoader());
}
 
Example 12
Source File: SharedContextEvaluator.java    From jdk8u_nashorn 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 13
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);
}