classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Patch: file resources require canonicalized names


From: Anthony Green
Subject: [cp-patches] Patch: file resources require canonicalized names
Date: Fri, 16 Sep 2005 15:51:49 -0700

I just checked in the following patch, which was approved by tromey.

2005-09-15  Anthony Green  <address@hidden>

        PR libgcj/20198
        * java/net/URLClassLoader.java (FileURLLoader.getResource): File
        resources should all have canonicalized names.


Index: java/net/URLClassLoader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/URLClassLoader.java,v
retrieving revision 1.36
diff -u -r1.36 URLClassLoader.java
--- java/net/URLClassLoader.java        9 Sep 2005 21:42:58 -0000       1.36
+++ java/net/URLClassLoader.java        16 Sep 2005 22:48:33 -0000
@@ -535,9 +535,16 @@
     /** get resource with the name "name" in the file url */
     Resource getResource(String name)
     {
-      File file = new File(dir, name);
-      if (file.exists() && !file.isDirectory())
-        return new FileResource(this, name, file);
+      try 
+       {
+         File file = new File(dir, name).getCanonicalFile();
+         if (file.exists() && !file.isDirectory())
+           return new FileResource(this, file.path(), file);
+       }
+      catch (IOException e)
+       {
+         // Fall through...
+       }
       return null;
     }
   }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]