RFR: 8359707: Add classfile modification code to RedefineClassHelper [v2]
Coleen Phillimore
coleenp at openjdk.org
Mon Jun 23 20:44:19 UTC 2025
On Mon, 23 Jun 2025 15:47:40 GMT, Leonid Mesnik <lmesnik at openjdk.org> 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
More information about the serviceability-dev
mailing list