On Tue, 26 Jan 2021 07:54:35 GMT, Chris Plummer <[email protected]> wrote:

>> Hi Yasumasa,
>> 
>> It looks good to me.
>> I have one minor question.
>> 
>> This loop in the test is a little bit confusing as it has not more than one 
>> iteration:
>> 55             while (itr.hasNext()) {
>> 56                 ObjectMonitor mon = (ObjectMonitor)itr.next();
>> 57                 Oop oop = heap.newOop(mon.object());
>> 58                 System.out.println("Monitor found: " + 
>> oop.getKlass().getName().asString());
>> 59                 return;
>> 60             }
>> Would it better to replace it with if-statement?
>> 
>> Thanks,
>> Serguei
>
> I'd say that's a bug, and probably what was meant is to do a `println` for 
> every monitor found, not just the first one. So what you would want then is 
> to bracket the `while` loop with `if (itr.hasNext()) {` and move the `return` 
> outside the `while` loop but still inside the `if` block.

I agree, it can be a bug.
There was this suggestion from Dan:
`Is it reasonable to expect at least one ObjectMonitor to be found?`
 so, I assumed, this loop is implementing it.

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

PR: https://git.openjdk.java.net/jdk/pull/1910

Reply via email to