aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannesw <none@none>2014-11-21 20:17:02 +0100
committerhannesw <none@none>2014-11-21 20:17:02 +0100
commit422aa12f3ece2332330f86c1666ae223a3ab8bba (patch)
treea2461054771a5d7ec1520d7c2b63d4e6e7191c3a
parent06e746a850245491260559b769b23dbc7a3c1fd8 (diff)
downloadnashorn-422aa12f3ece2332330f86c1666ae223a3ab8bba.tar.gz
8064789: Nashorn should just warn on code store instantiation error
Reviewed-by: attila, lagergren
-rw-r--r--src/jdk/nashorn/internal/runtime/CodeStore.java16
-rw-r--r--src/jdk/nashorn/internal/runtime/Context.java8
2 files changed, 12 insertions, 12 deletions
diff --git a/src/jdk/nashorn/internal/runtime/CodeStore.java b/src/jdk/nashorn/internal/runtime/CodeStore.java
index 0e85beeb..4e745ff4 100644
--- a/src/jdk/nashorn/internal/runtime/CodeStore.java
+++ b/src/jdk/nashorn/internal/runtime/CodeStore.java
@@ -82,10 +82,9 @@ public abstract class CodeStore implements Loggable {
* 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
@@ -103,9 +102,14 @@ public abstract class CodeStore implements Loggable {
} catch (final AccessControlException e) {
context.getLogger(CodeStore.class).warning("failed to load code store provider ", e);
}
- final CodeStore store = new DirectoryCodeStore(context);
- store.initLogger(context);
- return store;
+ 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 directory ", e);
+ return null;
+ }
}
diff --git a/src/jdk/nashorn/internal/runtime/Context.java b/src/jdk/nashorn/internal/runtime/Context.java
index 86369ab7..9e851998 100644
--- a/src/jdk/nashorn/internal/runtime/Context.java
+++ b/src/jdk/nashorn/internal/runtime/Context.java
@@ -509,11 +509,7 @@ public final class Context {
}
if (env._persistent_cache) {
- try {
- codeStore = newCodeStore(this);
- } catch (final IOException e) {
- throw new RuntimeException("Error initializing code cache", e);
- }
+ codeStore = newCodeStore(this);
}
// print version info if asked.
@@ -1200,7 +1196,7 @@ public final class Context {
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) {