RFR [10]: 8186517: sun.nio.cs.StandardCharsets$Aliases and ClassMap can be lazily loaded

Claes Redestad claes.redestad at oracle.com
Thu Aug 24 11:46:18 UTC 2017


On 2017-08-24 12:24, Peter Levart wrote:
> Hi Claes,
>
> On 08/24/2017 12:13 AM, Claes Redestad wrote:
>>
>>>>
>>>> This allows us to lazily load the $Cache class too, further reducing
>>>> work done during System.initPhase1:
>>>>
>>>> http://cr.openjdk.java.net/~redestad/8186517/jdk.02/
>>>>
>>>
>> /Claes
>
> According to 2nd webrev, StandardCharsets.charsetForName("UTF-8") 
> returns a different instance than 
> StandardCharsets.charsetForName("utf-8"). Perhaps the argument of 
> lookup() should 1st be passed through 
> canonicalize(toLower(charsetName)) and then used in the 3 special-case 
> ifs..

Hm, canonicalize is unnecessary for the three special cases (and central 
to the optimization, since canonicalize init Aliases and Classes), but 
we could ensure that the three special cases get populated into the 
Cache when it initializes so that we'll maintain the "same object" (not 
sure it really matters, since these three are all stateless, and 
equality in the cache layers are all comparing the name, never object 
identity).

I'm working on some other improvements to this patch and will update 
shortly.

/Claes


More information about the nio-dev mailing list