changeset 23769:e461495852b7

8039181: Persistent code store does not use absolute paths internally Reviewed-by: sundar, lagergren
author hannesw
date Thu, 03 Apr 2014 17:35:13 +0200
parents 7c0614b75e23
children cdedd86695a0
files nashorn/src/jdk/nashorn/internal/runtime/CodeStore.java
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/nashorn/src/jdk/nashorn/internal/runtime/CodeStore.java	Wed Apr 02 18:26:57 2014 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/CodeStore.java	Thu Apr 03 17:35:13 2014 +0200
@@ -70,16 +70,16 @@
      * @throws IOException
      */
     public CodeStore(final String path, final int minSize) throws IOException {
-        this.dir = new File(path);
+        this.dir = checkDirectory(path);
         this.minSize = minSize;
-        checkDirectory(this.dir);
     }
 
-    private static void checkDirectory(final File dir) throws IOException {
+    private static File checkDirectory(final String path) throws IOException {
         try {
-            AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+            return AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
                 @Override
-                public Void run() throws IOException {
+                public File run() throws IOException {
+                    final File dir = new File(path).getAbsoluteFile();
                     if (!dir.exists() && !dir.mkdirs()) {
                         throw new IOException("Could not create directory: " + dir);
                     } else if (!dir.isDirectory()) {
@@ -87,7 +87,7 @@
                     } else if (!dir.canRead() || !dir.canWrite()) {
                         throw new IOException("Directory not readable or writable: " + dir);
                     }
-                    return null;
+                    return dir;
                 }
             });
         } catch (PrivilegedActionException e) {