Misleading documentation for class java.nio.charset.spi.CharsetProvider
Christian Schulte
cs at schulte.it
Thu Dec 6 22:03:11 UTC 2012
Am 12/06/12 18:50, schrieb Alan Bateman:
> On 06/12/2012 17:26, Christian Schulte wrote:
>> Hello,
>>
>> I am not sure if this is the correct mailing list to send this mail to.
>> Please apologize any inconvenience caused.
>>
>> The JDK 7 documentation of class java.nio.charset.spi.CharsetProvider
>> states the following:
>>
>> [...]
>> Charset providers are looked up via the current thread's context class
>> loader.
>> [...]
>>
>> Looking at method 'private static Iterator providers()' of class
>> 'java.nio.charset.Charset', the above documentation seems incorrect
>> since that method uses the system class loader.
>>
>> ClassLoader cl = ClassLoader.getSystemClassLoader();
>> ServiceLoader<CharsetProvider> sl =
>> ServiceLoader.load(CharsetProvider.class, cl);
>>
>> Is this intended ?
>>
> This is a long standing issue (going back to 1.4), we should remove this
> from the javadoc.
Or update the code to use the thread context class loader if possible.
This would allow using custom charset providers with e.g. Webstart.
Anyway. Thanks for taking a look.
--
Christian Schulte
More information about the core-libs-dev
mailing list