This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: java.net.URL
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Sat, 27 Sep 2003 14:40:18 +0200
- Subject: FYI: Patch: java.net.URL
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello list,
I commited the the attached patch to trunk to make java.net.URL closer
to classpath's versions and fix the cache access.
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/dYUyWSOgCCdjSDsRAiQ4AJ9nrb46s0u1bephnZYU0oeT1gg0eQCgkw+t
qSaR+M4kGsgXpWsU+ttA9Os=
=91yN
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2196
diff -u -b -B -r1.2196 ChangeLog
--- ChangeLog 26 Sep 2003 22:02:04 -0000 1.2196
+++ ChangeLog 27 Sep 2003 12:36:01 -0000
@@ -1,5 +1,12 @@
2003-09-27 Michael Koch <konqueror@gmx.de>
+ * java/net/URL.java (getURLStreamHandler):
+ Check if we have to use cache before trying to retrieve handler from
+ cache. Rename facName to clsName to match classpath more. Reformated
+ some little pieces.
+
+2003-09-27 Michael Koch <konqueror@gmx.de>
+
* gnu/java/nio/SelectionKeyImpl.java
(ch): Make package-private again. Jikes found this bug.
Jeff Sturm submitted PR12426 for this to bugzilla
Index: java/net/URL.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URL.java,v
retrieving revision 1.24
diff -u -b -B -r1.24 URL.java
--- java/net/URL.java 2 Aug 2003 06:31:02 -0000 1.24
+++ java/net/URL.java 27 Sep 2003 12:36:01 -0000
@@ -753,18 +753,21 @@
{
URLStreamHandler ph;
- // See if a handler has been cached for this protocol.
+ // First, see if a protocol handler is in our cache.
+ if (cache_handlers)
+ {
if ((ph = (URLStreamHandler) ph_cache.get(protocol)) != null)
return ph;
+ }
// If a non-default factory has been set, use it to find the protocol.
if (factory != null)
{
- ph = factory.createURLStreamHandler(protocol);
+ ph = factory.createURLStreamHandler (protocol);
}
else if (protocol.equals ("core"))
{
- ph = new gnu.gcj.protocol.core.Handler ();
+ ph = new gnu.gcj.protocol.core.Handler();
}
else if (protocol.equals ("file"))
{
@@ -778,7 +781,7 @@
// fix this problem. If other protocols are required in a
// statically linked application they will need to be handled in
// the same way as "file".
- ph = new gnu.gcj.protocol.file.Handler ();
+ ph = new gnu.gcj.protocol.file.Handler();
}
// Non-default factory may have returned null or a factory wasn't set.
@@ -793,22 +796,30 @@
propVal = (propVal == null) ? "" : (propVal + "|");
propVal = propVal + "gnu.gcj.protocol|sun.net.www.protocol";
- StringTokenizer pkgPrefix = new StringTokenizer(propVal, "|");
+ // Finally loop through our search path looking for a match.
+ StringTokenizer pkgPrefix = new StringTokenizer (ph_search_path, "|");
+
do
{
- String facName = pkgPrefix.nextToken() + "." + protocol +
- ".Handler";
+ String clsName = pkgPrefix.nextToken() + "." + protocol + ".Handler";
+
try
{
- ph = (URLStreamHandler) Class.forName(facName).newInstance();
+ Object obj = Class.forName (clsName).newInstance();
+
+ if (!(obj instanceof URLStreamHandler))
+ continue;
+ else
+ ph = (URLStreamHandler) obj;
}
catch (Exception e)
{
// Can't instantiate; handler still null, go on to next element.
}
- } while ((ph == null ||
- ! (ph instanceof URLStreamHandler)) &&
- pkgPrefix.hasMoreTokens());
+ }
+ while ((ph == null ||
+ !(ph instanceof URLStreamHandler))
+ && pkgPrefix.hasMoreTokens());
}
// Update the hashtable with the new protocol handler.