Review (Updated) : 4884238 : Constants for Standard Charsets
mike.duigou at oracle.com
Tue Apr 19 17:23:41 PDT 2011
On Apr 19 2011, at 04:52 , Ulf Zibis wrote:
> Am 19.04.2011 00:24, schrieb Mike Duigou:
>> Hello All;
>> I have updated the webrev for the standard Charset constants based upon feedback received from the earlier reviews. The constants class is now named StandardCharset rather than Charsets in mimicry of the class naming used by NIO.2 (JSR 203). According to the conventions used by JSR 203 and elsewhere in JDK a "Charsets" class would be for static utility methods rather than solely constants.
>> The DEFAULT_CHARSET definition is also now removed. The Charset.getDefaultCharset() method makes it more clear that the value is not a constant across all all JVM instances.
>> Also now included is a small unit test and replacement of several uses of Charset.forname() for standard charset names within the platform.
>> The latest webrev :
>> Any other remaining feeback?
> Reading 'StandardCharset' one expects _the_ standard charset, but we have a collection of 6 here, so I'm for 'StandardCharsets' similar to e.g. j.u.z.ZipConstants, j.u.z.ZipConstants64, ...
See my response to Mark for the singular vs plural issue.
> I think, we should catch the problem at the source. ... In my approach from Bug 100098 - Make sun.nio.cs.* charset objects light-weight such a class is named 'FastCharset'.
Unfortunately any we at a very late stage in Java 7's development and the degree of change required by 100098 are not possible. This issue itself may also be rejected solely for missing impending deadlines. I can't comment at all about the prospects for Java 8 as I am not generally involved with charset/unicode work. This issue is a one time involvement with Charset for me.
> So I tend to prefer the original request from 4884238 (have the canonical names as constants), as the lookup via Charset.forName(...) then could be very fast compared to the anyway following heavy de/encoding work.
I think that in most uses a constant of the Charset is more useful as that's what's desired for use. I am not opposed to having visible constants for the charset names but I don't think it's as useful as the Charset objects. The performance of Charset.forName() is a separate matter.
More information about the core-libs-dev