RFR: 8372787: ModuleReader should throw IOException consistently when using --patch-module and ModuleReader is closed [v2]

Jaikiran Pai jpai at openjdk.org
Mon Dec 1 10:56:02 UTC 2025


On Mon, 1 Dec 2025 10:38:39 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/module/ModulePatcher.java line 314:
>> 
>>> 312:          */
>>> 313:         public Resource findResource(String name) throws IOException {
>>> 314:             ensureOpen();
>> 
>> Unlike the other methods which have been updated to call the `ensureOpen()`, this `findResource(...)` method isn't part of the `ModuleReader` interface. This only gets called from the `BuiltinClassLoader` when defining a `Class`. I looked up that code in `BuiltinClassLoader` and it already has a catch clause to handle `IOException`, so it felt right to add the `ensureOpen()` check here too.
>
> It would be a serious bug if we could somehow close the ModuleReader under the feet of the built-in class loaders. We could potentially use an assert here.

I have updated the PR to use an assert here instead of ensureOpen()

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28569#discussion_r2576588373


More information about the core-libs-dev mailing list