RFR: 8359707: Add classfile modification code to RedefineClassHelper [v2]
Leonid Mesnik
lmesnik at openjdk.org
Mon Jun 23 15:51:32 UTC 2025
On Mon, 23 Jun 2025 12:43:28 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> test/lib/RedefineClassHelper.java line 68:
>>
>>> 66:
>>> 67: private static byte[] getBytecodes(ClassLoader loader, String name) throws Exception {
>>> 68: InputStream is = loader.getResourceAsStream(name + ".class");
>>
>> I think this should be
>> try(InputStream is = loader.getResourceAsStream(name + ".class");) {
>> ...
>
> 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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25857#discussion_r2161944047
More information about the serviceability-dev
mailing list