From ba80a8b2647cbb1c15e6fa4489df9fc48f480136 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 16 Sep 2005 22:57:10 +0000 Subject: [PATCH] re PR classpath/20198 (java.security.CodeSource.getLocation output is different than expected) PR libgcj/20198 * java/net/URLClassLoader.java (FileURLLoader.getResource): File resources should all have canonicalized names. From-SVN: r104360 --- libjava/ChangeLog | 6 ++++++ libjava/java/net/URLClassLoader.java | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 3520d8c3c08..7777f3a6bb9 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +2005-09-16 Anthony Green + + PR libgcj/20198 + * java/net/URLClassLoader.java (FileURLLoader.getResource): File + resources should all have canonicalized names. + 2005-09-15 Tom Tromey PR libgcj/16032: diff --git a/libjava/java/net/URLClassLoader.java b/libjava/java/net/URLClassLoader.java index 5d48c02b296..2a6f87c4093 100644 --- a/libjava/java/net/URLClassLoader.java +++ b/libjava/java/net/URLClassLoader.java @@ -610,9 +610,16 @@ public class URLClassLoader extends SecureClassLoader /** get resource with the name "name" in the file url */ Resource getResource(String name) { - File file = new File(dir, name); - if (file.exists()) - 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; } }