On Thu, 24 Sep 2020 00:38:32 GMT, Igor Ignatyev <[email protected]> wrote:
>> test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachineDescriptor/VirtualMachineDescriptor01/VirtualMachineDescriptor01.java
>> line 112:
>>> 110:
>>> 111: TestUtils.assertEquals(targetVMDesc.hashCode(),
>>> targetVMDesc2.hashCode(),
>>> 112: "VirtualMachineDescriptor.hashCode() returns
>>> different values for '" + targetVMDesc + "' and
>>> '" + targetVMDesc2 + "'");
>>
>> Does `TestUtils.assertEquals` print out actual/expected value as well? If
>> not, dropping `hashCode` printout here loses
>> debugging data.
>
> it does for both a reference type and `int`, [TestUtils.java]:
> public static void assertEquals(int i1, int i2) {
> if (i1 != i2) {
> throw new TestFailure(
> format("Check failed: %d != %d", i1, i2));
> }
> }
>
> public static void assertEquals(Object obj1, Object obj2, Object
> errorMessage) {
> assertTrue(obj1.equals(obj2), new LazyFormatString("%s: [%s] !=
> [%s]", errorMessage, obj1, obj2));
> }
> [TestUtils.java]:
> https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/test/TestUtils.java#L70
OK, cool.
>> test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine03/VirtualMachine03.java
>> line 78:
>>
>>> 76: } finally {
>>> 77: vm2.detach();
>>> 78: }
>>
>> Is nesting needed here because `vm1`/`vm2` can be `null` at `finally`? Then
>> it is cleaner IMO to just do:
>>
>> } finally {
>> if (vm1 != null) vm1.detach();
>> if (vm2 != null) vm2.detach();
>> }
>
> nested try-finally isn't semantically equivalent with the snippet you
> suggested, `VirtualMachine::detach` can throw
> IOE, so I'd prefer to two finally blocks to guarantee that we at least to
> detach from both vm-s.
Okay then.
-------------
PR: https://git.openjdk.java.net/jdk/pull/311