RFR [10]: 8186517: sun.nio.cs.StandardCharsets$Aliases and ClassMap can be lazily loaded
Peter Levart
peter.levart at gmail.com
Thu Aug 24 21:18:47 UTC 2017
On 08/24/2017 10:00 PM, Claes Redestad wrote:
>
>
> On 2017-08-24 20:06, Claes Redestad wrote:
>>>>
>>>> Hm... What about aliases? Would you hard-code them in the
>>>> individual Charset classes (UTF_8, US_ASCII, ISO_8859_1)? They are
>>>> currently generated in the body of sun...StandardCharsets.
>>>>
>>>> Regards, Peter
>>>>
>>>
>>> ...perhaps the generator could be modified to generate a static
>>> method per charset, returning an array of aliases instead of a
>>> static final field. StandardCharsets would become very light then as
>>> its <clinit> would not do much.
>>
>> Right, I was looking at it from a different angle (generate them
>> directly into each corresponding class), but this way is actually
>> much easier and should be easy enough to roll into this patch.
>
> Done:
>
> http://cr.openjdk.java.net/~redestad/8186517/jdk.03/
>
> Manually verified that generated charsets look correct and ran all
> charset tests without issue.
>
>>
>> Should be a nice reduction in retained objects on minimal apps.
>
> 425 fewer objects allocated, -16.5Kb.
>
> /Claes
Very nice!
The synchronization issue with iteration and unsynchronized lookup()
still remains, and it's awkward that init() still has to "patch" the
aliases (must the hack remain in place?), but that could be solved in a
separate followup issue as well as optimization for public
java.nio.charset.StandardCharsets.
The startup performance issue has been nicely handled, so this looks
good to me, Claes.
Regards, Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20170824/cd183dee/attachment.html>
More information about the nio-dev
mailing list