Regression in GCJ 3.3 in parsing property files

Ranjit Mathew rmathew@hotmail.com
Tue Feb 18 20:06:00 GMT 2003


> Ranjit> The VMClassLoader has only "file:.\" as the base URL for
> Ranjit> searching the file "build.properties".
>> Where does this string come from?

For each component of the CLASSPATH, it creates a base URL - the
one above is created for the default "." in the CLASSPATH.
> Is it really valid for a file: URL to use `\' as the separator?
> My suspicion is that this sort of URL should always use `/'.

Yes. I verified with Sun's JDK 1.4.1 which has no problems in
reading from a "file:.\\build.properties" resource.
> Note that one known bug in this area is that File.toURL doesn't
> convert the path separator. I think it should.

I'll look into this...
> Or, I could be mistaken about all this and we would have to fix the
> URL parsing code. Can you find out?

The following patch to the parseURL( ) method fixes the problem for 
me:
Index: java/net/URLStreamHandler.java
===================================================================
--- java/net/URLStreamHandler.java	2003年02月19日 00:33:08.000000000 +0530
+++ java/net/URLStreamHandler.java	2003年02月19日 00:51:32.000000000 +0530
@@ -40,4 +40,5 @@
 
 import java.io.IOException;
+import java.io.File;
 
 /*
@@ -177,6 +178,14 @@
 {
 	// Context is available, but only override it if there is a new file.
-	file = file.substring(0, file.lastIndexOf('/'))
-		+ '/' + spec.substring(start, end);
+ char sepChar = '/';
+ int lastSlash = file.lastIndexOf (sepChar);
+ if ((lastSlash < 0) && (File.separatorChar != sepChar))
+ {
+ sepChar = File.separatorChar;
+ lastSlash = file.lastIndexOf (sepChar);
+ }
+ 
+	file = file.substring(0, lastSlash)
+		+ sepChar + spec.substring(start, end);
 	ref = null;
 }
Ranjit.
-- 
Ranjit Mathew Email: rmathew AT hotmail DOT com
Bangalore, 
INDIA. Web: http://ranjitmathew.tripod.com/


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /