On Tue, 26 Jan 2021 08:23:28 GMT, Serguei Spitsyn <[email protected]> wrote:
>> 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.
I updated testcase to use `if` rather than `while`.
As I said in [previous
comment](https://github.com/openjdk/jdk/pull/1910/files#r562807477), I want to
check hether SA can find the monitors here. We don't need to iterate all
monitors when we check it to work.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1910