RFR: 8335896: Source launcher should set TCCL [v2]

Christian Stein cstein at openjdk.org
Tue Jul 16 08:46:21 UTC 2024


On Tue, 16 Jul 2024 08:13:14 GMT, Christian Stein <cstein at openjdk.org> wrote:

>> Would the constructor of `MemoryClassLoader` be a better place?
>> 
>> Because `context.newClassLoaderFor()` has two exit-points where an instance of `MemoryClassLoader` is created.
>
> The try-catch cares for `ClassNotFoundException` instances thrown by `Class.forName()` - which doesn't initialize the main class. But swapping the lines to read:
> 
>             Thread.currentThread().setContextClassLoader(loader);
>             firstClass = Class.forName(firstClassName, false, loader);
> 
> should better ensure that the TCCL is set before the initializer for the main class runs.

I found a better way to move the `TCCL`-related above the try-catch block.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20097#discussion_r1678999300


More information about the compiler-dev mailing list