Request for review: Race conditions in java.nio.charset.Charset

Ulf Zibis Ulf.Zibis at gmx.de
Fri Oct 9 20:47:58 UTC 2009


Am 08.10.2009 06:40, Martin Buchholz schrieb:
> If you can show that a simple test program that appears to access
> only 2 charsets in fact causes accesses to 3 or 4, that is a serious
> problem with the 2-element cache.
>   

See attachment:
- simple JUnit test class
- NetBeans project, ready to build and run
- charset usage log

> People at Google are working on better caches,
> but I don't think they are quite ready today.
>
> Perhaps, instead of a small charset cache,
> we could cache all the charsets, but for the
> large charsets like GB18030, we could,
> inside the charset implementation, cache the
> large data tables using a soft reference, and recompute
> as needed.  Then most of the static memory used
> by an unused charset could be reclaimed.
>   

I have implemented exactly this here:
https://bugs.openjdk.java.net/show_bug.cgi?id=100098


-Ulf

-------------- next part --------------
A non-text attachment was scrubbed...
Name: CharsetTest.java
Type: java/*
Size: 1491 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20091009/cf24f60a/CharsetTest.java>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nio_charset_usage.zip
Type: application/x-zip-compressed
Size: 21418 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20091009/cf24f60a/nio_charset_usage.zip>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: charset_usage.log
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20091009/cf24f60a/charset_usage.log>


More information about the core-libs-dev mailing list