RFR: 8306914: Implementation of JEP Launch Multi-File Source-Code Programs [v4]

Christian Stein cstein at openjdk.org
Fri Oct 27 11:00:40 UTC 2023


On Wed, 25 Oct 2023 13:33:37 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Christian Stein has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Main method determines the main class now
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/MemoryContext.java line 227:
> 
>> 225:         var modulePathModules = modulePathFinder.findAll().stream().map(ModuleReference::descriptor).map(ModuleDescriptor::name).toList();
>> 226:         if (!modulePathModules.isEmpty()) {
>> 227:             var modulePathConfiguration = bootLayer.configuration().resolveAndBind(modulePathFinder, ModuleFinder.of(), Set.copyOf(modulePathModules));
> 
> Some (or all) of the modules on the applications module path may be in the boot layer, I don't think you want to have another instance of these modules in the child layer. So I think check this line, it looks like the first two parameters needs to be swapped so that only modules not found in the boot layer will be resolved.

Will change the line as suggested.

> src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/MemoryContext.java line 228:
> 
>> 226:         if (!modulePathModules.isEmpty()) {
>> 227:             var modulePathConfiguration = bootLayer.configuration().resolveAndBind(modulePathFinder, ModuleFinder.of(), Set.copyOf(modulePathModules));
>> 228:             var modulePathLayer = ModuleLayer.defineModulesWithOneLoader(modulePathConfiguration, List.of(bootLayer), parent).layer();
> 
> Since you don't need the Controller then it may be simpler to use just `bootLayer.defineModulesWithOneLoader(modulePathConfiguration, parent);`

Will change the line as suggested.

> src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/MemoryContext.java line 246:
> 
>> 244:         memoryController.addOpens(module, mainClassNamePackageName, getClass().getModule());
>> 245: 
>> 246:         return memoryLayer.findLoader(applicationModule.name()).loadClass(mainClassName);
> 
> The defining class loader for the main class will be memoryClassLoader, right?

Right. Only the memory class loader has the bytes stored for the main class and other "source-file" classes referenced by the main class.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1374406318
PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1374405723
PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1374404524


More information about the compiler-dev mailing list