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

Print this page

        

@@ -80,14 +80,13 @@
 
     /**
      * Returns a new code store instance.
      *
      * @param context the current context
-     * @return The instance
-     * @throws IOException If an error occurs
+     * @return The instance, or null if code store could not be created
      */
-    public static CodeStore newCodeStore(final Context context) throws IOException {
+    public static CodeStore newCodeStore(final Context context) {
         final Class<CodeStore> baseClass = CodeStore.class;
         try {
             // security check first
             final SecurityManager sm = System.getSecurityManager();
             if (sm != null) {

@@ -101,13 +100,18 @@
                 return store;
             }
         } catch (final AccessControlException e) {
             context.getLogger(CodeStore.class).warning("failed to load code store provider ", e);
         }
+        try {
         final CodeStore store = new DirectoryCodeStore(context);
         store.initLogger(context);
         return store;
+        } catch (final IOException e) {
+            context.getLogger(CodeStore.class).warning("failed to create cache dir", e);
+            return null;
+        }
     }
 
 
     /**
      * Store a compiled script in the cache.