RFR: 8335896: Source launcher should set TCCL [v2]
Christian Stein
cstein at openjdk.org
Tue Jul 16 09:24:51 UTC 2024
On Tue, 16 Jul 2024 08:49:47 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> I found a better way to move the `TCCL`-related above the try-catch block.
>
> Good, I was puzzled why newClassLoaderFor was declared to throw CNFE. Related question is do you know why it uses Class.forName without running the class initializer? I guess I expected it would load loader.loadClass(firstClassName) and let the initializer run (it's going to run a bit later anyway). Main thing is that the initializer may do anything and the TCCL needs to be set before that executes (which is what you have now).
For reference, the single-file launcher `execute()` method had: `Class.forName(mainClassName, true, cl);`
IIRC, we decided to call with `false` here in order to delay initialization for when the first class is not the class with the main method - accounting for the new protocal that also tries to match the file name with a later type name within the file.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20097#discussion_r1679055521
More information about the compiler-dev
mailing list