jdk.nashorn.internal.runtime.options.Options Java Examples

The following examples show how to use jdk.nashorn.internal.runtime.options.Options. 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: ContextTest.java    From openjdk-8 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 ScriptObject 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 #2
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 #3
Source File: ContextTest.java    From TencentKona-8 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 #4
Source File: RecompilableScriptFunctionData.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the AST serializer executor service used for in-memory serialization of split functions' ASTs.
 * It is created with an unbounded queue (so it can queue any number of pending tasks). Its core and max
 * threads is the same, but they are all allowed to time out so when there's no work, they can all go
 * away. The threads will be daemons, and they will time out if idle for a minute. Their priority is also
 * slightly lower than normal priority as we'd prefer the CPU to keep running the program; serializing
 * split function is a memory conservation measure (it allows us to release the AST), it can wait a bit.
 * @return an executor service with above described characteristics.
 */
private static ExecutorService createAstSerializerExecutorService() {
    final int threads = Math.max(1, Options.getIntProperty("nashorn.serialize.threads", Runtime.getRuntime().availableProcessors() / 2));
    final ThreadPoolExecutor service = new ThreadPoolExecutor(threads, threads, 1L, TimeUnit.MINUTES, new LinkedBlockingDeque<Runnable>(),
            new ThreadFactory() {
                @Override
                public Thread newThread(final Runnable r) {
                    final Thread t = new Thread(r, "Nashorn AST Serializer");
                    t.setDaemon(true);
                    t.setPriority(Thread.NORM_PRIORITY - 1);
                    return t;
                }
            });
    service.allowCoreThreadTimeOut(true);
    return service;
}
 
Example #5
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 #6
Source File: ContextTest.java    From jdk8u60 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 #7
Source File: CompilerTest.java    From jdk8u60 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 #8
Source File: RecompilableScriptFunctionData.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the AST serializer executor service used for in-memory serialization of split functions' ASTs.
 * It is created with an unbounded queue (so it can queue any number of pending tasks). Its core and max
 * threads is the same, but they are all allowed to time out so when there's no work, they can all go
 * away. The threads will be daemons, and they will time out if idle for a minute. Their priority is also
 * slightly lower than normal priority as we'd prefer the CPU to keep running the program; serializing
 * split function is a memory conservation measure (it allows us to release the AST), it can wait a bit.
 * @return an executor service with above described characteristics.
 */
private static ExecutorService createAstSerializerExecutorService() {
    final int threads = Math.max(1, Options.getIntProperty("nashorn.serialize.threads", Runtime.getRuntime().availableProcessors() / 2));
    final ThreadPoolExecutor service = new ThreadPoolExecutor(threads, threads, 1L, TimeUnit.MINUTES, new LinkedBlockingDeque<Runnable>(),
            new ThreadFactory() {
                @Override
                public Thread newThread(final Runnable r) {
                    final Thread t = new Thread(r, "Nashorn AST Serializer");
                    t.setDaemon(true);
                    t.setPriority(Thread.NORM_PRIORITY - 1);
                    return t;
                }
            });
    service.allowCoreThreadTimeOut(true);
    return service;
}
 
Example #9
Source File: ContextTest.java    From hottub 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 #10
Source File: ContextTest.java    From openjdk-jdk8u 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 #11
Source File: CompilerTest.java    From openjdk-jdk8u 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: RecompilableScriptFunctionData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the AST serializer executor service used for in-memory serialization of split functions' ASTs.
 * It is created with an unbounded queue (so it can queue any number of pending tasks). Its core and max
 * threads is the same, but they are all allowed to time out so when there's no work, they can all go
 * away. The threads will be daemons, and they will time out if idle for a minute. Their priority is also
 * slightly lower than normal priority as we'd prefer the CPU to keep running the program; serializing
 * split function is a memory conservation measure (it allows us to release the AST), it can wait a bit.
 * @return an executor service with above described characteristics.
 */
private static ExecutorService createAstSerializerExecutorService() {
    final int threads = Math.max(1, Options.getIntProperty("nashorn.serialize.threads", Runtime.getRuntime().availableProcessors() / 2));
    final ThreadPoolExecutor service = new ThreadPoolExecutor(threads, threads, 1L, TimeUnit.MINUTES, new LinkedBlockingDeque<Runnable>(),
            new ThreadFactory() {
                @Override
                public Thread newThread(final Runnable r) {
                    final Thread t = new Thread(r, "Nashorn AST Serializer");
                    t.setDaemon(true);
                    t.setPriority(Thread.NORM_PRIORITY - 1);
                    return t;
                }
            });
    service.allowCoreThreadTimeOut(true);
    return service;
}
 
Example #13
Source File: ContextTest.java    From openjdk-jdk8u-backup 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 #14
Source File: ContextTest.java    From openjdk-jdk8u-backup 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 #15
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 #16
Source File: CompilerTest.java    From openjdk-jdk8u-backup 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 #17
Source File: CompilerTest.java    From hottub 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 #18
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 #19
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 #20
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 #21
Source File: ContextTest.java    From jdk8u_nashorn 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 #22
Source File: ContextTest.java    From jdk8u_nashorn 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 #23
Source File: RecompilableScriptFunctionData.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the AST serializer executor service used for in-memory serialization of split functions' ASTs.
 * It is created with an unbounded queue (so it can queue any number of pending tasks). Its core and max
 * threads is the same, but they are all allowed to time out so when there's no work, they can all go
 * away. The threads will be daemons, and they will time out if idle for a minute. Their priority is also
 * slightly lower than normal priority as we'd prefer the CPU to keep running the program; serializing
 * split function is a memory conservation measure (it allows us to release the AST), it can wait a bit.
 * @return an executor service with above described characteristics.
 */
private static ExecutorService createAstSerializerExecutorService() {
    final int threads = Math.max(1, Options.getIntProperty("nashorn.serialize.threads", Runtime.getRuntime().availableProcessors() / 2));
    final ThreadPoolExecutor service = new ThreadPoolExecutor(threads, threads, 1L, TimeUnit.MINUTES, new LinkedBlockingDeque<Runnable>(),
            new ThreadFactory() {
                @Override
                public Thread newThread(final Runnable r) {
                    final Thread t = new Thread(r, "Nashorn AST Serializer");
                    t.setDaemon(true);
                    t.setPriority(Thread.NORM_PRIORITY - 1);
                    return t;
                }
            });
    service.allowCoreThreadTimeOut(true);
    return service;
}
 
Example #24
Source File: CompilerTest.java    From openjdk-8-source 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 #25
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 #26
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 #27
Source File: ParserTest.java    From TencentKona-8 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: 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 #29
Source File: OptimisticTypesPersistence.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private static File createBaseCacheDir() {
    if(MAX_FILES == 0 || Options.getBooleanProperty("nashorn.typeInfo.disabled")) {
        return null;
    }
    try {
        return createBaseCacheDirPrivileged();
    } catch(final Exception e) {
        reportError("Failed to create cache dir", e);
        return null;
    }
}
 
Example #30
Source File: OptimisticTypesPersistence.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private static int getMaxFiles() {
    final String str = Options.getStringProperty("nashorn.typeInfo.maxFiles", null);
    if (str == null) {
        return DEFAULT_MAX_FILES;
    } else if ("unlimited".equals(str)) {
        return UNLIMITED_FILES;
    }
    return Math.max(0, Integer.parseInt(str));
}