summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2006-12-07 21:58:41 +0000
committerMark Wielaard <mark@klomp.org>2006-12-07 21:58:41 +0000
commit987287b346229fcf0419bb93a13a52d6a1800d8e (patch)
tree4666ec629c29274260223989834e76be1c947073
parentf8ff60363031c138dbc9899373f43ba15fab7208 (diff)
downloadclasspath-987287b346229fcf0419bb93a13a52d6a1800d8e.tar.gz
* java/net/URL.java (URL(URL,String,URLStreamHandler,boolean)): New
private constructor. (URL(URL,String,URLStreamHandler)): Call new constructor. (URL(URL,String)): Likewise. (URL(String)): Likewise.
-rw-r--r--ChangeLog8
-rw-r--r--java/net/URL.java32
2 files changed, 36 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a4edce17..5f57e3ce5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-12-07 Mark Wielaard <mark@klomp.org>
+
+ * java/net/URL.java (URL(URL,String,URLStreamHandler,boolean)): New
+ private constructor.
+ (URL(URL,String,URLStreamHandler)): Call new constructor.
+ (URL(URL,String)): Likewise.
+ (URL(String)): Likewise.
+
2006-12-07 Tom Tromey <tromey@redhat.com>
* NEWS: Mention ASM.
diff --git a/java/net/URL.java b/java/net/URL.java
index ed7decc79..8f72d0687 100644
--- a/java/net/URL.java
+++ b/java/net/URL.java
@@ -322,7 +322,8 @@ public final class URL implements Serializable
*/
public URL(String spec) throws MalformedURLException
{
- this((URL) null, spec != null ? spec : "", (URLStreamHandler) null);
+ this((URL) null, spec != null ? spec : "", (URLStreamHandler) null,
+ false);
}
/**
@@ -343,7 +344,9 @@ public final class URL implements Serializable
*/
public URL(URL context, String spec) throws MalformedURLException
{
- this(context, spec, (context == null) ? (URLStreamHandler)null : context.ph);
+ this(context, spec,
+ (context == null) ? (URLStreamHandler) null : context.ph,
+ false);
}
/**
@@ -377,6 +380,23 @@ public final class URL implements Serializable
public URL(URL context, String spec, URLStreamHandler ph)
throws MalformedURLException
{
+ this(context, spec, ph, true);
+ }
+
+ /**
+ * Private constructor called by all other constructors taking
+ * a context and spec.
+ *
+ * @param context The context in which to parse the specification
+ * @param spec The string to parse as an URL
+ * @param ph The stream handler for the URL
+ * @param phFromUser Whether or not the user supplied the URLStreamHandler
+ *
+ */
+ private URL(URL context, String spec, URLStreamHandler ph,
+ boolean phFromUser)
+ throws MalformedURLException
+ {
/* A protocol is defined by the doc as the substring before a ':'
* as long as the ':' occurs before any '/'.
*
@@ -397,7 +417,11 @@ public final class URL implements Serializable
if ((colon = spec.indexOf("://", 1)) > 0
&& ((colon < slash || slash < 0))
&& ! spec.regionMatches(colon, "://:", 0, 4))
- context = null;
+ {
+ context = null;
+ if (! phFromUser)
+ ph = null;
+ }
boolean protocolSpecified = false;
@@ -458,7 +482,7 @@ public final class URL implements Serializable
if (ph != null)
{
SecurityManager s = System.getSecurityManager();
- if (s != null)
+ if (s != null && phFromUser)
s.checkPermission(new NetPermission("specifyStreamHandler"));
this.ph = ph;