more fine-grained jython hack that also plays with java 9

This commit is contained in:
Robert Muir 2015-07-14 15:42:21 -04:00
parent 38054ff4ee
commit caab1df111

View File

@ -88,14 +88,16 @@ public class BootstrapForTesting {
// add permissions to everything in classpath // add permissions to everything in classpath
for (URL url : ((URLClassLoader)BootstrapForTesting.class.getClassLoader()).getURLs()) { for (URL url : ((URLClassLoader)BootstrapForTesting.class.getClassLoader()).getURLs()) {
Path path = PathUtils.get(url.toURI()); Path path = PathUtils.get(url.toURI());
if (path.toString().endsWith(".jar")) { // resource itself
// jar itself perms.add(new FilePermission(path.toString(), "read,readlink"));
perms.add(new FilePermission(path.toString(), "read,readlink")); // classes underneath
// crazy jython... perms.add(new FilePermission(path.toString() + path.getFileSystem().getSeparator() + "-", "read,readlink"));
Security.addPath(perms, path.getParent().resolve("Lib"), "read,readlink");
} else { // crazy jython...
// classes String filename = path.getFileName().toString();
Security.addPath(perms, path, "read,readlink"); if (filename.contains("jython") && filename.endsWith(".jar")) {
// just enough so it won't fail when it does not exist
perms.add(new FilePermission(path.getParent().resolve("Lib").toString(), "read,readlink"));
} }
} }
// java.io.tmpdir // java.io.tmpdir