8064789: Nashorn should just warn on code store instantiation error

Fri, 21 Nov 2014 20:17:02 +0100

author
hannesw
date
Fri, 21 Nov 2014 20:17:02 +0100
changeset 1104
c22dd9ae7ff0
parent 1103
fcd4684a739c
child 1105
c3a510b73875

8064789: Nashorn should just warn on code store instantiation error
Reviewed-by: attila, lagergren

src/jdk/nashorn/internal/runtime/CodeStore.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/Context.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/internal/runtime/CodeStore.java	Thu Nov 20 11:27:48 2014 -0800
     1.2 +++ b/src/jdk/nashorn/internal/runtime/CodeStore.java	Fri Nov 21 20:17:02 2014 +0100
     1.3 @@ -82,10 +82,9 @@
     1.4       * Returns a new code store instance.
     1.5       *
     1.6       * @param context the current context
     1.7 -     * @return The instance
     1.8 -     * @throws IOException If an error occurs
     1.9 +     * @return The instance, or null if code store could not be created
    1.10       */
    1.11 -    public static CodeStore newCodeStore(final Context context) throws IOException {
    1.12 +    public static CodeStore newCodeStore(final Context context) {
    1.13          final Class<CodeStore> baseClass = CodeStore.class;
    1.14          try {
    1.15              // security check first
    1.16 @@ -103,9 +102,14 @@
    1.17          } catch (final AccessControlException e) {
    1.18              context.getLogger(CodeStore.class).warning("failed to load code store provider ", e);
    1.19          }
    1.20 -        final CodeStore store = new DirectoryCodeStore(context);
    1.21 -        store.initLogger(context);
    1.22 -        return store;
    1.23 +        try {
    1.24 +            final CodeStore store = new DirectoryCodeStore(context);
    1.25 +            store.initLogger(context);
    1.26 +            return store;
    1.27 +        } catch (final IOException e) {
    1.28 +            context.getLogger(CodeStore.class).warning("failed to create cache directory ", e);
    1.29 +            return null;
    1.30 +        }
    1.31      }
    1.32  
    1.33  
     2.1 --- a/src/jdk/nashorn/internal/runtime/Context.java	Thu Nov 20 11:27:48 2014 -0800
     2.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java	Fri Nov 21 20:17:02 2014 +0100
     2.3 @@ -509,11 +509,7 @@
     2.4          }
     2.5  
     2.6          if (env._persistent_cache) {
     2.7 -            try {
     2.8 -                codeStore = newCodeStore(this);
     2.9 -            } catch (final IOException e) {
    2.10 -                throw new RuntimeException("Error initializing code cache", e);
    2.11 -            }
    2.12 +            codeStore = newCodeStore(this);
    2.13          }
    2.14  
    2.15          // print version info if asked.
    2.16 @@ -1200,7 +1196,7 @@
    2.17          FunctionNode functionNode = null;
    2.18          // We only use the code store here if optimistic types are disabled. With optimistic types, initial compilation
    2.19          // just creates a thin wrapper, and actual code is stored per function in RecompilableScriptFunctionData.
    2.20 -        final boolean useCodeStore = env._persistent_cache && !env._parse_only && !env._optimistic_types;
    2.21 +        final boolean useCodeStore = codeStore != null && !env._parse_only && !env._optimistic_types;
    2.22          final String cacheKey = useCodeStore ? CodeStore.getCacheKey(0, null) : null;
    2.23  
    2.24          if (useCodeStore) {

mercurial