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

The following examples show how to use jdk.nashorn.internal.runtime.options.Options#getBooleanProperty() . 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: OptimisticTypesPersistence.java    From TencentKona-8 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 2
Source File: OptimisticTypesPersistence.java    From jdk8u60 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 3
Source File: OptimisticTypesPersistence.java    From openjdk-jdk8u 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 4
Source File: OptimisticTypesPersistence.java    From openjdk-jdk8u-backup 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 5
Source File: OptimisticTypesPersistence.java    From openjdk-jdk9 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 6
Source File: OptimisticTypesPersistence.java    From hottub 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 7
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 8
Source File: DebugLogger.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * A logger can be paired with a property, e.g. {@code --log:codegen:info} is equivalent to {@code -Dnashorn.codegen.log}
 *
 * @param loggerName name of logger - this is the unique key with which it can be identified
 * @param property   system property activating the logger on {@code info} level
 */
public DebugLogger(final String loggerName, final String property) {
    if (property != null && Options.getBooleanProperty(property)) {
        this.logger = Logging.getOrCreateLogger(loggerName, Level.INFO);
    } else {
        this.logger = Logging.getLogger(loggerName);
    }
    this.isEnabled = logger.getLevel() != Level.OFF;
}
 
Example 9
Source File: Context.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor
 *
 * @param options options from command line or Context creator
 * @param errors  error manger
 * @param out     output writer for this Context
 * @param err     error writer for this Context
 * @param appLoader application class loader
 * @param classFilter class filter to use
 */
public Context(final Options options, final ErrorManager errors, final PrintWriter out, final PrintWriter err, final ClassLoader appLoader, final ClassFilter classFilter) {
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new RuntimePermission(NASHORN_CREATE_CONTEXT));
    }

    this.classFilter = classFilter;
    this.env       = new ScriptEnvironment(options, out, err);
    this._strict   = env._strict;
    if (env._loader_per_compile) {
        this.scriptLoader = null;
        this.uniqueScriptId = null;
    } else {
        this.scriptLoader = createNewLoader();
        this.uniqueScriptId = new AtomicLong();
    }
    this.errors    = errors;

    // if user passed -classpath option, make a URLClassLoader with that and
    // the app loader as the parent.
    final String classPath = options.getString("classpath");
    if (!env._compile_only && classPath != null && !classPath.isEmpty()) {
        // make sure that caller can create a class loader.
        if (sm != null) {
            sm.checkCreateClassLoader();
        }
        this.appLoader = NashornLoader.createClassLoader(classPath, appLoader);
    } else {
        this.appLoader = appLoader;
    }

    final int cacheSize = env._class_cache_size;
    if (cacheSize > 0) {
        classCache = new ClassCache(cacheSize);
    }

    if (env._persistent_cache) {
        codeStore = newCodeStore(this);
    }

    // print version info if asked.
    if (env._version) {
        getErr().println("nashorn " + Version.version());
    }

    if (env._fullversion) {
        getErr().println("nashorn full version " + Version.fullVersion());
    }

    if (Options.getBooleanProperty("nashorn.fields.dual")) {
        fieldMode = FieldMode.DUAL;
    } else if (Options.getBooleanProperty("nashorn.fields.objects")) {
        fieldMode = FieldMode.OBJECTS;
    } else {
        fieldMode = FieldMode.AUTO;
    }

    initLoggers();
}
 
Example 10
Source File: Context.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor
 *
 * @param options options from command line or Context creator
 * @param errors  error manger
 * @param out     output writer for this Context
 * @param err     error writer for this Context
 * @param appLoader application class loader
 * @param classFilter class filter to use
 */
public Context(final Options options, final ErrorManager errors, final PrintWriter out, final PrintWriter err, final ClassLoader appLoader, final ClassFilter classFilter) {
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new RuntimePermission(NASHORN_CREATE_CONTEXT));
    }

    this.classFilter = classFilter;
    this.env       = new ScriptEnvironment(options, out, err);
    this._strict   = env._strict;
    this.appLoader = appLoader;
    if (env._loader_per_compile) {
        this.scriptLoader = null;
        this.uniqueScriptId = null;
    } else {
        this.scriptLoader = createNewLoader();
        this.uniqueScriptId = new AtomicLong();
    }
    this.errors    = errors;

    // if user passed -classpath option, make a class loader with that and set it as
    // thread context class loader so that script can access classes from that path.
    final String classPath = options.getString("classpath");
    if (!env._compile_only && classPath != null && !classPath.isEmpty()) {
        // make sure that caller can create a class loader.
        if (sm != null) {
            sm.checkPermission(new RuntimePermission("createClassLoader"));
        }
        this.classPathLoader = NashornLoader.createClassLoader(classPath);
    } else {
        this.classPathLoader = null;
    }

    final int cacheSize = env._class_cache_size;
    if (cacheSize > 0) {
        classCache = new ClassCache(cacheSize);
    }

    if (env._persistent_cache) {
        codeStore = newCodeStore(this);
    }

    // print version info if asked.
    if (env._version) {
        getErr().println("nashorn " + Version.version());
    }

    if (env._fullversion) {
        getErr().println("nashorn full version " + Version.fullVersion());
    }

    if (Options.getBooleanProperty("nashorn.fields.dual")) {
        fieldMode = FieldMode.DUAL;
    } else if (Options.getBooleanProperty("nashorn.fields.objects")) {
        fieldMode = FieldMode.OBJECTS;
    } else {
        fieldMode = FieldMode.AUTO;
    }

    initLoggers();
}
 
Example 11
Source File: Context.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor
 *
 * @param options options from command line or Context creator
 * @param errors  error manger
 * @param out     output writer for this Context
 * @param err     error writer for this Context
 * @param appLoader application class loader
 * @param classFilter class filter to use
 */
public Context(final Options options, final ErrorManager errors, final PrintWriter out, final PrintWriter err, final ClassLoader appLoader, final ClassFilter classFilter) {
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new RuntimePermission(NASHORN_CREATE_CONTEXT));
    }

    this.classFilter = classFilter;
    this.env       = new ScriptEnvironment(options, out, err);
    this._strict   = env._strict;
    if (env._loader_per_compile) {
        this.scriptLoader = null;
        this.uniqueScriptId = null;
    } else {
        this.scriptLoader = createNewLoader();
        this.uniqueScriptId = new AtomicLong();
    }
    this.errors    = errors;

    // if user passed -classpath option, make a URLClassLoader with that and
    // the app loader as the parent.
    final String classPath = options.getString("classpath");
    if (!env._compile_only && classPath != null && !classPath.isEmpty()) {
        // make sure that caller can create a class loader.
        if (sm != null) {
            sm.checkCreateClassLoader();
        }
        this.appLoader = NashornLoader.createClassLoader(classPath, appLoader);
    } else {
        this.appLoader = appLoader;
    }

    final int cacheSize = env._class_cache_size;
    if (cacheSize > 0) {
        classCache = new ClassCache(cacheSize);
    }

    if (env._persistent_cache) {
        codeStore = newCodeStore(this);
    }

    // print version info if asked.
    if (env._version) {
        getErr().println("nashorn " + Version.version());
    }

    if (env._fullversion) {
        getErr().println("nashorn full version " + Version.fullVersion());
    }

    if (Options.getBooleanProperty("nashorn.fields.dual")) {
        fieldMode = FieldMode.DUAL;
    } else if (Options.getBooleanProperty("nashorn.fields.objects")) {
        fieldMode = FieldMode.OBJECTS;
    } else {
        fieldMode = FieldMode.AUTO;
    }

    initLoggers();
}
 
Example 12
Source File: Context.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor
 *
 * @param options options from command line or Context creator
 * @param errors  error manger
 * @param out     output writer for this Context
 * @param err     error writer for this Context
 * @param appLoader application class loader
 * @param classFilter class filter to use
 */
public Context(final Options options, final ErrorManager errors, final PrintWriter out, final PrintWriter err, final ClassLoader appLoader, final ClassFilter classFilter) {
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new RuntimePermission(NASHORN_CREATE_CONTEXT));
    }

    this.classFilter = classFilter;
    this.env       = new ScriptEnvironment(options, out, err);
    this._strict   = env._strict;
    if (env._loader_per_compile) {
        this.scriptLoader = null;
        this.uniqueScriptId = null;
    } else {
        this.scriptLoader = createNewLoader();
        this.uniqueScriptId = new AtomicLong();
    }
    this.errors    = errors;

    // if user passed -classpath option, make a URLClassLoader with that and
    // the app loader as the parent.
    final String classPath = options.getString("classpath");
    if (!env._compile_only && classPath != null && !classPath.isEmpty()) {
        // make sure that caller can create a class loader.
        if (sm != null) {
            sm.checkCreateClassLoader();
        }
        this.appLoader = NashornLoader.createClassLoader(classPath, appLoader);
    } else {
        this.appLoader = appLoader;
    }

    final int cacheSize = env._class_cache_size;
    if (cacheSize > 0) {
        classCache = new ClassCache(cacheSize);
    }

    if (env._persistent_cache) {
        codeStore = newCodeStore(this);
    }

    // print version info if asked.
    if (env._version) {
        getErr().println("nashorn " + Version.version());
    }

    if (env._fullversion) {
        getErr().println("nashorn full version " + Version.fullVersion());
    }

    if (Options.getBooleanProperty("nashorn.fields.dual")) {
        fieldMode = FieldMode.DUAL;
    } else if (Options.getBooleanProperty("nashorn.fields.objects")) {
        fieldMode = FieldMode.OBJECTS;
    } else {
        fieldMode = FieldMode.AUTO;
    }

    initLoggers();
}
 
Example 13
Source File: Context.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor
 *
 * @param options options from command line or Context creator
 * @param errors  error manger
 * @param out     output writer for this Context
 * @param err     error writer for this Context
 * @param appLoader application class loader
 * @param classFilter class filter to use
 */
public Context(final Options options, final ErrorManager errors, final PrintWriter out, final PrintWriter err, final ClassLoader appLoader, final ClassFilter classFilter) {
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new RuntimePermission(NASHORN_CREATE_CONTEXT));
    }

    this.classFilter = classFilter;
    this.env       = new ScriptEnvironment(options, out, err);
    this._strict   = env._strict;
    if (env._loader_per_compile) {
        this.scriptLoader = null;
        this.uniqueScriptId = null;
    } else {
        this.scriptLoader = createNewLoader();
        this.uniqueScriptId = new AtomicLong();
    }
    this.errors    = errors;

    // if user passed --module-path, we create a module class loader with
    // passed appLoader as the parent.
    final String modulePath = env._module_path;
    ClassLoader appCl = null;
    if (!env._compile_only && modulePath != null && !modulePath.isEmpty()) {
        // make sure that caller can create a class loader.
        if (sm != null) {
            sm.checkCreateClassLoader();
        }
        appCl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
            @Override
            public ClassLoader run() {
                return createModuleLoader(appLoader, modulePath, env._add_modules);
            }
        });
    } else {
        appCl = appLoader;
    }

    // if user passed -classpath option, make a URLClassLoader with that and
    // the app loader or module app loader as the parent.
    final String classPath = env._classpath;
    if (!env._compile_only && classPath != null && !classPath.isEmpty()) {
        // make sure that caller can create a class loader.
        if (sm != null) {
            sm.checkCreateClassLoader();
        }
        appCl = NashornLoader.createClassLoader(classPath, appCl);
    }

    this.appLoader = appCl;
    this.dynamicLinker = Bootstrap.createDynamicLinker(this.appLoader, env._unstable_relink_threshold);

    final int cacheSize = env._class_cache_size;
    if (cacheSize > 0) {
        classCache = new ClassCache(this, cacheSize);
    }

    if (env._persistent_cache) {
        codeStore = newCodeStore(this);
    }

    // print version info if asked.
    if (env._version) {
        getErr().println("nashorn " + Version.version());
    }

    if (env._fullversion) {
        getErr().println("nashorn full version " + Version.fullVersion());
    }

    if (Options.getBooleanProperty("nashorn.fields.dual")) {
        fieldMode = FieldMode.DUAL;
    } else if (Options.getBooleanProperty("nashorn.fields.objects")) {
        fieldMode = FieldMode.OBJECTS;
    } else {
        fieldMode = FieldMode.AUTO;
    }

    initLoggers();
}
 
Example 14
Source File: Context.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor
 *
 * @param options options from command line or Context creator
 * @param errors  error manger
 * @param out     output writer for this Context
 * @param err     error writer for this Context
 * @param appLoader application class loader
 * @param classFilter class filter to use
 */
public Context(final Options options, final ErrorManager errors, final PrintWriter out, final PrintWriter err, final ClassLoader appLoader, final ClassFilter classFilter) {
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new RuntimePermission(NASHORN_CREATE_CONTEXT));
    }

    this.classFilter = classFilter;
    this.env       = new ScriptEnvironment(options, out, err);
    this._strict   = env._strict;
    this.appLoader = appLoader;
    if (env._loader_per_compile) {
        this.scriptLoader = null;
        this.uniqueScriptId = null;
    } else {
        this.scriptLoader = createNewLoader();
        this.uniqueScriptId = new AtomicLong();
    }
    this.errors    = errors;

    // if user passed -classpath option, make a class loader with that and set it as
    // thread context class loader so that script can access classes from that path.
    final String classPath = options.getString("classpath");
    if (!env._compile_only && classPath != null && !classPath.isEmpty()) {
        // make sure that caller can create a class loader.
        if (sm != null) {
            sm.checkPermission(new RuntimePermission("createClassLoader"));
        }
        this.classPathLoader = NashornLoader.createClassLoader(classPath);
    } else {
        this.classPathLoader = null;
    }

    final int cacheSize = env._class_cache_size;
    if (cacheSize > 0) {
        classCache = new ClassCache(cacheSize);
    }

    if (env._persistent_cache) {
        codeStore = newCodeStore(this);
    }

    // print version info if asked.
    if (env._version) {
        getErr().println("nashorn " + Version.version());
    }

    if (env._fullversion) {
        getErr().println("nashorn full version " + Version.fullVersion());
    }

    if (Options.getBooleanProperty("nashorn.fields.dual")) {
        fieldMode = FieldMode.DUAL;
    } else if (Options.getBooleanProperty("nashorn.fields.objects")) {
        fieldMode = FieldMode.OBJECTS;
    } else {
        fieldMode = FieldMode.AUTO;
    }

    initLoggers();
}
 
Example 15
Source File: Context.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor
 *
 * @param options options from command line or Context creator
 * @param errors  error manger
 * @param out     output writer for this Context
 * @param err     error writer for this Context
 * @param appLoader application class loader
 * @param classFilter class filter to use
 */
public Context(final Options options, final ErrorManager errors, final PrintWriter out, final PrintWriter err, final ClassLoader appLoader, final ClassFilter classFilter) {
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new RuntimePermission(NASHORN_CREATE_CONTEXT));
    }

    this.classFilter = classFilter;
    this.env       = new ScriptEnvironment(options, out, err);
    this._strict   = env._strict;
    if (env._loader_per_compile) {
        this.scriptLoader = null;
        this.uniqueScriptId = null;
    } else {
        this.scriptLoader = createNewLoader();
        this.uniqueScriptId = new AtomicLong();
    }
    this.errors    = errors;

    // if user passed -classpath option, make a URLClassLoader with that and
    // the app loader as the parent.
    final String classPath = options.getString("classpath");
    if (!env._compile_only && classPath != null && !classPath.isEmpty()) {
        // make sure that caller can create a class loader.
        if (sm != null) {
            sm.checkCreateClassLoader();
        }
        this.appLoader = NashornLoader.createClassLoader(classPath, appLoader);
    } else {
        this.appLoader = appLoader;
    }

    final int cacheSize = env._class_cache_size;
    if (cacheSize > 0) {
        classCache = new ClassCache(cacheSize);
    }

    if (env._persistent_cache) {
        codeStore = newCodeStore(this);
    }

    // print version info if asked.
    if (env._version) {
        getErr().println("nashorn " + Version.version());
    }

    if (env._fullversion) {
        getErr().println("nashorn full version " + Version.fullVersion());
    }

    if (Options.getBooleanProperty("nashorn.fields.dual")) {
        fieldMode = FieldMode.DUAL;
    } else if (Options.getBooleanProperty("nashorn.fields.objects")) {
        fieldMode = FieldMode.OBJECTS;
    } else {
        fieldMode = FieldMode.AUTO;
    }

    initLoggers();
}