src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java

Print this page

        

@@ -507,15 +507,11 @@
         if (cacheSize > 0) {
             classCache = new ClassCache(this, cacheSize);
         }
 
         if (env._persistent_cache) {
-            try {
                 codeStore = newCodeStore(this);
-            } catch (final IOException e) {
-                throw new RuntimeException("Error initializing code cache", e);
-            }
         }
 
         // print version info if asked.
         if (env._version) {
             getErr().println("nashorn " + Version.version());

@@ -1198,11 +1194,11 @@
 
         StoredScript storedScript = null;
         FunctionNode functionNode = null;
         // We only use the code store here if optimistic types are disabled. With optimistic types, initial compilation
         // just creates a thin wrapper, and actual code is stored per function in RecompilableScriptFunctionData.
-        final boolean useCodeStore = env._persistent_cache && !env._parse_only && !env._optimistic_types;
+        final boolean useCodeStore = codeStore != null && !env._parse_only && !env._optimistic_types;
         final String cacheKey = useCodeStore ? CodeStore.getCacheKey(0, null) : null;
 
         if (useCodeStore) {
             storedScript = codeStore.load(source, cacheKey);
         }