RFR: 8340404: Clarify CharsetProvider deployment on application module path [v6]
Justin Lu
jlu at openjdk.org
Sat Sep 21 18:15:34 UTC 2024
On Sat, 21 Sep 2024 05:55:46 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Hi Alan,
>>
>> I think you're right that the CCL is not used.
>>
>> The standard charsets are loaded via the SystemClassLoader, the extended are loaded via the platformClassLoader, and BazProvider does appear to be loaded via the SystemClassLoader. See below,
>>
>>
>> // Assert default context class loader is the system class loader
>> Thread.currentThread().getContextClassLoader(); // default context class loader -> jdk.internal.loader.ClassLoaders$AppClassLoader at 1d81eb93
>> ClassLoader.getSystemClassLoader(); // system class loader -> jdk.internal.loader.ClassLoaders$AppClassLoader at 1d81eb93
>>
>> // Change the default context class loader
>> Thread.currentThread().setContextClassLoader(new FooLoader()); // Change default context class loader to not be the system
>>
>> // Check the class loaders for the various Charsets
>> Charset.availableCharsets().get("utf-8").getClassLoader(); // standard -> null
>> Charset.availableCharsets().get("Big5").getClassLoader(); // extended -> jdk.internal.loader.ClassLoaders$PlatformClassLoader at 55a95ab1
>> Charset.availableCharsets().get("BAZ").getClassLoader(); // provider -> jdk.internal.loader.ClassLoaders$AppClassLoader at 1d81eb93
>> Thread.currentThread().getContextClassLoader(); // context class loader -> CharsetProviderAsModuleTest$FooLoader at 1d15c6cc
>>
>>
>> Can we simply omit the line:
>>
>> "_Charset providers are looked up via the current thread's context class loader_".
>
> Thanks for checking. I remember [JDK-4619777 ](https://bugs.openjdk.org/browse/JDK-4619777) and it's possible there are one or two other JBS issue on the topic. It may be been interesting to include a charset provider with a dynamically loaded application at one point but seems less interesting in 2024. So I think we should just update the spec to align with the long standing behavior, meaning specify that the charset provider must be visible to the system class loader. I think "by some other platform-specific means" by can be dropped too.
Updated in https://github.com/openjdk/jdk/pull/21076/commits/d90f6ca0dcc1f5fd6d74af58c4cb2b0d14d1666e.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21076#discussion_r1769632649
More information about the nio-dev
mailing list