summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2003-01-17 19:14:06 +0000
committerMark Wielaard <mark@klomp.org>2003-01-17 19:14:06 +0000
commit766d8320d89a65c9793a14fe1f649d253f2e033b (patch)
treeaaa9d92ec7828ebd53276fb006314e781688271e
parentc9c7944e34f097639a1d3cc8a9db0876fdcc04bc (diff)
downloadclasspath-766d8320d89a65c9793a14fe1f649d253f2e033b.tar.gz
2003-01-17 Mark Wielaard <mark@klomp.org>
Jeroen Frijters <jeroen@sumatra.nl> * java/net/URLClassLoader.java (Resource.getCodeSource): Fix check certs == null. (getCanonicalFileURL): Removed method. (JarURLLoader): Don't call removed method. (FileURLLoader): Likewise. (FileURLLoader.getResource): Don't canonicalize file name. 2003-01-17 Mark Wielaard <mark@klomp.org> * java/lang/ClassLoader.java (normalize): Removed. (getResource): Don't call normalize. (getResources): Likewise.
-rw-r--r--ChangeLog16
-rw-r--r--java/lang/ClassLoader.java40
-rw-r--r--java/net/URLClassLoader.java47
3 files changed, 21 insertions, 82 deletions
diff --git a/ChangeLog b/ChangeLog
index 03988b562..34c7c4574 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,20 @@
2003-01-17 Mark Wielaard <mark@klomp.org>
+ Jeroen Frijters <jeroen@sumatra.nl>
+
+ * java/net/URLClassLoader.java (Resource.getCodeSource):
+ Fix check certs == null.
+ (getCanonicalFileURL): Removed method.
+ (JarURLLoader): Don't call removed method.
+ (FileURLLoader): Likewise.
+ (FileURLLoader.getResource): Don't canonicalize file name.
+
+2003-01-17 Mark Wielaard <mark@klomp.org>
+
+ * java/lang/ClassLoader.java (normalize): Removed.
+ (getResource): Don't call normalize.
+ (getResources): Likewise.
+
+2003-01-17 Mark Wielaard <mark@klomp.org>
* NEWS: Describe java.io.(VM)ObjectStreamClass.
* configure.in (AC_OUTPUT): Add vm/reference/java/io/Makefile.
diff --git a/java/lang/ClassLoader.java b/java/lang/ClassLoader.java
index e6ffb5fe8..53a16e460 100644
--- a/java/lang/ClassLoader.java
+++ b/java/lang/ClassLoader.java
@@ -516,7 +516,6 @@ public abstract class ClassLoader
*/
public URL getResource(String name)
{
- name = normalize(name);
URL result;
if (parent == null)
@@ -551,7 +550,6 @@ public abstract class ClassLoader
*/
public final Enumeration getResources(String name) throws IOException
{
- name = normalize(name);
Enumeration parentResources;
if (parent == null)
parentResources = VMClassLoader.getResources(name);
@@ -561,44 +559,6 @@ public abstract class ClassLoader
}
/**
- * Normalizes a resource path name. This removes all ./ from the start and
- * all further '//', "/../" and "/./" from the given name.
- */
- private static String normalize(String resource)
- {
- while (resource.startsWith("./"))
- resource = resource.substring(2);
-
- int index = resource.indexOf("//");
- while (index != -1)
- {
- resource = resource.substring(0, index) + resource.substring(index+1);
- index = resource.indexOf("//");
- }
-
- index = resource.indexOf("/../");
- while (index != -1)
- {
- int last = resource.lastIndexOf('/', index-1);
- if (last != -1)
- resource = resource.substring(0, last+1)
- + resource.substring(index+4);
- else
- resource = resource.substring(index+4);
- index = resource.indexOf("/../");
- }
-
- index = resource.indexOf("/./");
- while (index != -1)
- {
- resource = resource.substring(0, index) + resource.substring(index+2);
- index = resource.indexOf("/./");
- }
-
- return resource;
- }
-
- /**
* Called whenever all locations of a named resource are needed.
* It is called by <code>getResources()</code> after it has called
* <code>parent.getResources()</code>. The results are combined by
diff --git a/java/net/URLClassLoader.java b/java/net/URLClassLoader.java
index 0bc19d011..d7fc77f8a 100644
--- a/java/net/URLClassLoader.java
+++ b/java/net/URLClassLoader.java
@@ -238,7 +238,7 @@ public class URLClassLoader extends SecureClassLoader
CodeSource getCodeSource()
{
Certificate[] certs = getCertificates();
- if (certs != null)
+ if (certs == null)
return loader.noCertCodeSource;
else
return new CodeSource(loader.baseURL, certs);
@@ -272,47 +272,17 @@ public class URLClassLoader extends SecureClassLoader
}
/**
- * Returns the given URL with a canonicalized file path name when it
- * is has the file protocol. Otherwise (or when the file part of the
- * URL couldn't be canonicalized) it returns the original String.
- * It makes sure that if the original file part ended with a file
- * separator that the new file part also ends with a separator.
- */
- static URL getCanonicalFileURL(URL url)
- {
- if ("file".equals(url.getProtocol()))
- {
- try
- {
- String f = url.getFile();
- File file = new File(f).getCanonicalFile();
- String cf = file.toString();
- String sep = File.separator;
- if (f.endsWith(sep) && !cf.endsWith(sep))
- {
- cf += "/";
- }
- url = new URL("file", "", cf);
- }
- catch (IOException ignore)
- {
- }
- }
- return url;
- }
-
- /**
* A <code>JarURLLoader</code> is a type of <code>URLLoader</code>
* only loading from jar url.
*/
final static class JarURLLoader extends URLLoader
{
- final JarFile jarfile; // The canonical jar file for this url
+ final JarFile jarfile; // The jar file for this url
final URL baseJarURL; // Base jar: url for all resources loaded from jar
public JarURLLoader(URLClassLoader classloader, URL baseURL)
{
- super(classloader, getCanonicalFileURL(baseURL));
+ super(classloader, baseURL);
// cache url prefix for all resources in this jar url
String external = baseURL.toExternalForm();
@@ -495,11 +465,11 @@ public class URLClassLoader extends SecureClassLoader
*/
final static class FileURLLoader extends URLLoader
{
- File dir; //the canonical file for this file url
+ File dir; //the file for this file url
FileURLLoader(URLClassLoader classloader, URL url)
{
- super(classloader, getCanonicalFileURL(url));
+ super(classloader, url);
dir = new File(baseURL.getFile());
}
@@ -507,13 +477,6 @@ public class URLClassLoader extends SecureClassLoader
Resource getResource(String name)
{
File file = new File(dir, name);
- try
- {
- file = file.getCanonicalFile();
- }
- catch (IOException ignore)
- {
- }
if (file.exists() && !file.isDirectory())
return new FileResource(this, name, file);
return null;