On Wed, 14 Jan 2026 22:04:15 GMT, Kevin Rushforth <[email protected]> wrote:

> I'm not sure this is equivalent. Also, I'd like to see a test for this. In 
> general, adding null checks or other similar checks without understanding 
> them is not something we want to do.

To add a little more to this, replacing code like this:


    try {
        // do something
    } catch (NullPointerException npe) {
       // log or ignore or ...
    }


with something like this:


    if (check for null) {
       // log or ignore or ...
    } else {
        // do something
    }


is generally fine and usually easy to prove equivalence.

Unless I'm missing something, this PR doesn't do that, rather it takes a state 
-- startPos == -1 -- that currently causes an OOBE (which is silently ignored) 
and clamps the value so it will actually do something. That's not equivalent, 
at least not in all cases.

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

PR Comment: https://git.openjdk.org/jfx/pull/2037#issuecomment-3752024225

Reply via email to