RFR: 8336470: Source launcher should work with service loader SPI in unnamed module [v7]
Christian Stein
cstein at openjdk.org
Fri May 9 11:37:52 UTC 2025
On Fri, 9 May 2025 08:42:00 GMT, Christian Stein <cstein at openjdk.org> wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/MemoryClassLoader.java line 232:
>>
>>> 230: String binaryName = toBinaryName(name);
>>> 231: if (binaryName == null || sourceFileClasses.get(binaryName) == null) {
>>> 232: return toResourceInRootPath(name); // can be null
>>
>> "can be null" is a bit confusing here. I initially read it that name can be null but this isn't possible, at least not with a well behaved class loader as the getResource methods are specified to reject null so will never delegate a null to findResource. The comment is really that it might return null (meaning not found).
>
> Yes. I can either update the comment to read `returning null here is expected by the caller` or refactor the method to read `toResourceInRootPathOrNull(String name)`. Another option would be to make the return type an `Optional<URL>` and handle the not-available case at the call site.
I removed the comment without touching any names nor return types.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20193#discussion_r2081488836
More information about the compiler-dev
mailing list