From 45778093ee7ed0de16f602140d07d962f5d8c0a5 Mon Sep 17 00:00:00 2001 From: Simon Oberhammer Date: Fri, 28 Dec 2012 12:06:01 +0100 Subject: [PATCH 1/2] jaffl version bump --- tools/admin/create.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/admin/create.js b/tools/admin/create.js index a093deea5..11407170c 100644 --- a/tools/admin/create.js +++ b/tools/admin/create.js @@ -78,7 +78,7 @@ function copyJars(home, dest, symlink) { var jars = [ "ringo-core.jar", "ivy/rhino-1.7R5-SNAPSHOT.jar", - "ivy/jaffl-0.5.11.jar", + "ivy/jaffl-0.5.12.jar", "ivy/jnr-posix-1.1.9.jar" ]; var libsrc = join(home, "lib"); From 3a1f5e9dc920bf44b0489319ff3f17c6d91587bc Mon Sep 17 00:00:00 2001 From: Simon Oberhammer Date: Fri, 28 Dec 2012 12:06:51 +0100 Subject: [PATCH 2/2] registering JVM shutdown hook now fails gracefully on GAE --- src/org/ringojs/engine/RhinoEngine.java | 34 ++++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/org/ringojs/engine/RhinoEngine.java b/src/org/ringojs/engine/RhinoEngine.java index a8f4a4708..f046e14bc 100644 --- a/src/org/ringojs/engine/RhinoEngine.java +++ b/src/org/ringojs/engine/RhinoEngine.java @@ -97,7 +97,7 @@ public RhinoEngine(RingoConfig config, Map globals) contextFactory = new RingoContextFactory(this, config); repositories = config.getRepositories(); wrapFactory = config.getWrapFactory(); - + loaders = new ModuleLoader[] { new JsModuleLoader(), new JsonModuleLoader(), new ClassModuleLoader() }; @@ -139,11 +139,15 @@ public RhinoEngine(RingoConfig config, Map globals) if (debugger != null) { debugger.setBreak(); } - Runtime.getRuntime().addShutdownHook(new Thread() { - public void run() { - shutdown(); - } - }); + try { + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + shutdown(); + } + }); + } catch (java.security.AccessControlException e) { + log.log(Level.WARNING, "Could not register shutdown hook due to security exception", e); + } } finally { Context.exit(); } @@ -550,7 +554,7 @@ protected Resource loadPackage(String moduleName, Repository localPath) return findResource(moduleName + "/index", loaders, localPath); } - + private Scriptable parseJsonResource(Resource resource) throws IOException { JsonParser parser = new JsonParser(Context.getCurrentContext(), globalScope); try { @@ -564,7 +568,7 @@ private Scriptable parseJsonResource(Resource resource) throws IOException { throw new RuntimeException(px); } } - + private String getStringProperty(Scriptable obj, String name, String defaultValue) { Object value = ScriptableObject.getProperty(obj, name); if (value != null && value != ScriptableObject.NOT_FOUND) { @@ -801,7 +805,7 @@ public Resource findResource(String path, ModuleLoader[] loaders, } res.setAbsolute(true); return res; - } else if (localRoot != null && + } else if (localRoot != null && (path.startsWith("./") || path.startsWith("../"))) { String newpath = localRoot.getRelativePath() + path; return findResource(newpath, loaders, null); @@ -833,7 +837,7 @@ public Repository findRepository(String path, Repository localPath) throws IOExc } return config.getRepository(normalizePath(path)); } - + public ModuleLoader getModuleLoader(Resource resource) { String name = resource.getName(); for (ModuleLoader loader : loaders) { @@ -864,23 +868,23 @@ public synchronized void addModuleLoader(String extension, Object value) { newLoaders[length] = new ScriptedModuleLoader(extension, function); loaders = newLoaders; } - + public synchronized void removeModuleLoader(String extension) { int length = loaders.length; for (int i = 0; i < length; i++) { - if (loaders[i] instanceof ScriptedModuleLoader && + if (loaders[i] instanceof ScriptedModuleLoader && extension.equals(loaders[i].getExtension())) { ModuleLoader[] newLoaders = new ModuleLoader[length - 1]; - if (i > 0) + if (i > 0) System.arraycopy(loaders, 0, newLoaders, 0, i); - if (i < length - 1) + if (i < length - 1) System.arraycopy(loaders, i + 1, newLoaders, i, length - i - 1); loaders = newLoaders; return; } } } - + public static String normalizePath(String path) { if (!path.contains("./")) { return path;