RFR: 8336470: Source launcher should work with service loader SPI in unnamed module [v15]

Alan Bateman alanb at openjdk.org
Fri May 16 05:28:03 UTC 2025


On Thu, 15 May 2025 19:59:20 GMT, Christian Stein <cstein at openjdk.org> wrote:

>> Please review this change adding a missing resource file test to the `MemoryClassLoader::findResource` override in order to resolve all files beneath the source root path in source launch mode - analog to what was already implemented for `MemoryClassLoader::getResource`.
>> 
>> With this change applied, files in `META-INF/services/` are resolved; allowing services providers being supplied in source form.
>
> Christian Stein has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 12 additional commits since the last revision:
> 
>  - Merge branch 'openjdk:master' into JDK-8336470-source-launcher-get-resources
>  - Revert change after JDK-8356678 being addressed
>  - Prevent FileSystemException on Unix-based file systems
>  - Prevent NPE by removing redundant check
>  - Removed redundant catch block
>  - Catch and rethrow IO exception
>  - Fix interim javac compilation
>  - Reuse internal resource resolver and remove confusing comment
>  - Update copyright year
>    
>    [skip ci]
>  - User copyright text w/o `"Classpath" exception`
>    
>    [skip ci]
>  - ... and 2 more: https://git.openjdk.org/jdk/compare/3a13630f...11956f24

src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/MemoryClassLoader.java line 284:

> 282:             var path = Resources.toFilePath(programDescriptor.sourceRootPath(), name);
> 283:             return path == null ? null : path.toUri().toURL();
> 284:         } catch (IOException e) {

toUri throws IOError so I think you will need handle this too, otherwise I think the updated toResourceInRootPath looks okay.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20193#discussion_r2092344247


More information about the compiler-dev mailing list