Commit 96c6b0e2 by Tom Tromey Committed by Tom Tromey

re PR classpath/20198 (java.security.CodeSource.getLocation output is different than expected)

	PR classpath/20198:
	* java/net/URLClassLoader.java (FileURLLoader): Added argument.
	(JarURLLoader): Likewise.
	(addURLImpl): Canonicalize file URLs.

From-SVN: r109844
parent a37a4460
2006-01-17 Tom Tromey <tromey@redhat.com>
PR classpath/20198:
* java/net/URLClassLoader.java (FileURLLoader): Added argument.
(JarURLLoader): Likewise.
(addURLImpl): Canonicalize file URLs.
2006-01-16 Mark Wielaard <mark@klomp.org> 2006-01-16 Mark Wielaard <mark@klomp.org>
Imported GNU Classpath 0.20 Imported GNU Classpath 0.20
......
/* URLClassLoader.java -- ClassLoader that loads classes from one or more URLs /* URLClassLoader.java -- ClassLoader that loads classes from one or more URLs
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -305,9 +305,10 @@ public class URLClassLoader extends SecureClassLoader ...@@ -305,9 +305,10 @@ public class URLClassLoader extends SecureClassLoader
Vector classPath; // The "Class-Path" attribute of this Jar's manifest Vector classPath; // The "Class-Path" attribute of this Jar's manifest
public JarURLLoader(URLClassLoader classloader, URL baseURL) public JarURLLoader(URLClassLoader classloader, URL baseURL,
URL absoluteUrl)
{ {
super(classloader, baseURL); super(classloader, baseURL, absoluteUrl);
// Cache url prefix for all resources in this jar url. // Cache url prefix for all resources in this jar url.
String external = baseURL.toExternalForm(); String external = baseURL.toExternalForm();
...@@ -601,10 +602,10 @@ public class URLClassLoader extends SecureClassLoader ...@@ -601,10 +602,10 @@ public class URLClassLoader extends SecureClassLoader
{ {
File dir; //the file for this file url File dir; //the file for this file url
FileURLLoader(URLClassLoader classloader, URL url) FileURLLoader(URLClassLoader classloader, URL url, URL absoluteUrl)
{ {
super(classloader, url); super(classloader, url, absoluteUrl);
dir = new File(baseURL.getFile()); dir = new File(absoluteUrl.getFile());
} }
/** get resource with the name "name" in the file url */ /** get resource with the name "name" in the file url */
...@@ -885,13 +886,44 @@ public class URLClassLoader extends SecureClassLoader ...@@ -885,13 +886,44 @@ public class URLClassLoader extends SecureClassLoader
String file = newUrl.getFile(); String file = newUrl.getFile();
String protocol = newUrl.getProtocol(); String protocol = newUrl.getProtocol();
// If we have a file: URL, we want to make it absolute
// here, before we decide whether it is really a jar.
URL absoluteURL;
if ("file".equals (protocol))
{
File dir = new File(file);
URL absUrl;
try
{
absoluteURL = dir.getCanonicalFile().toURL();
}
catch (IOException ignore)
{
try
{
absoluteURL = dir.getAbsoluteFile().toURL();
}
catch (MalformedURLException _)
{
// This really should not happen.
absoluteURL = newUrl;
}
}
}
else
{
// This doesn't hurt, and it simplifies the logic a
// little.
absoluteURL = newUrl;
}
// Check that it is not a directory // Check that it is not a directory
if ("gcjlib".equals(protocol)) if ("gcjlib".equals(protocol))
loader = new SoURLLoader(this, newUrl); loader = new SoURLLoader(this, newUrl);
else if (! (file.endsWith("/") || file.endsWith(File.separator))) else if (! (file.endsWith("/") || file.endsWith(File.separator)))
loader = new JarURLLoader(this, newUrl); loader = new JarURLLoader(this, newUrl, absoluteURL);
else if ("file".equals(protocol)) else if ("file".equals(protocol))
loader = new FileURLLoader(this, newUrl); loader = new FileURLLoader(this, newUrl, absoluteURL);
else if ("core".equals(protocol)) else if ("core".equals(protocol))
loader = new CoreURLLoader(this, newUrl); loader = new CoreURLLoader(this, newUrl);
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment