RFR: 8340404: Clarify CharsetProvider deployment on application module path [v5]

Justin Lu jlu at openjdk.org
Fri Sep 20 23:41:11 UTC 2024


On Fri, 20 Sep 2024 12:58:59 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Thanks for taking a look Alan. Your test comments should be addressed in https://github.com/openjdk/jdk/pull/21076/commits/790abd039dd08ca1e0575feca29f681a2507d902.
>> Did you have any comments on the current doc change?
>
>>  Did you have any comments on the current doc change?
> 
> I've been slow to reply on that because I'm not 100% sure if the spec is correct. Can you double check that the CCL is actually used. I think it uses the system class loader, and maybe the platform class loader for the extended charsets.

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_".

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21076#discussion_r1769354840


More information about the nio-dev mailing list