On Mon, 23 Jun 2025 15:47:40 GMT, Leonid Mesnik <[email protected]> wrote:
>> getBytecodes propagates the exception from getResourceAsStream. If I catch
>> IOException (?), what should it do?
>
> I didn't thought about this, but I think that's ok. I just propose to closed
> stream, not changing the exception handling. The
>
> try(InputStream is = loader.getResourceAsStream(name + ".class");) {
> InputStream is = loader.getResourceAsStream(name + ".class");
> byte[] buf = is.readAllBytes();
> System.out.println("sizeof(" + name + ".class) == " + buf.length);
> return buf;
> }
>
> has completely the same workflow, just closing stream so we don't have any
> resource leak.
Oh so this try is a try-with-resources and it'll close the stream? It compiles
without a catch clause.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25857#discussion_r2162492123