Name: nt126004 Date: 06/25/2002
FULL PRODUCT VERSION :
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)
FULL OPERATING SYSTEM VERSION :Al
A DESCRIPTION OF THE PROBLEM :
In JDK < 1.4 URLEncoder and URLDecoder only had 1 method each
In JDK >= 1.4 this method has been deprecated and the
suggested replacement has a different number of parameters
and, worse, throws a checked exception.
Since it seems from the documentation that passing anything
but "UTF-8" for the second parameter will lead to unreliable
results it would be much easier for developers upgrading
from 1.3 if there was a default implementation that didn't
throw an exception, something like
<pre>
public static String defaultEncode (String s) {
try {
return java.net.URLEncoder.encode (s, "UTF-8");
} catch (UnsupportedEncodingException ex) {
assert false;
return null;
}
}
</pre>
The assert false is justified since the JLS stipulates that
all virtual machines must support UTF-8 hence the exception
should never be thrown.
If we don't have this in the JDK then developers will have
to cut/paste this code everywhere or provide an alternative
implementation of URLEncoder/URLDecoder
REPRODUCIBILITY :
This bug can be reproduced always.
(Review ID: 158428)
======================================================================
- duplicates
-
JDK-8178704 Add Charset overloads to URLDecoder and URLEncoder
-
- Closed
-