From ba80a8b2647cbb1c15e6fa4489df9fc48f480136 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 16 Sep 2005 22:57:10 +0000 Subject: 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/java/net/URLClassLoader.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'libjava/java/net/URLClassLoader.java') diff --git a/libjava/java/net/URLClassLoader.java b/libjava/java/net/URLClassLoader.java index 5d48c02..2a6f87c 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; } } -- cgit v1.1