Withdrawn: 8266625: The method DiagnosticSource#findLine returns wrong results when using the boundary values
duke
duke at openjdk.java.net
Thu Jul 1 15:32:04 UTC 2021
On Thu, 6 May 2021 13:55:35 GMT, Guoxiong Li <gli at openjdk.org> wrote:
> Hi all,
>
> Currently, when the file object has N characters, the method `DiagnosticSource#findLine(N)` returns true, which is a wrong result. Becase the position is zero-based, the max index is `N-1`.
>
> The methods `getLineNumber`, `getColumnNumber` and `getLine`, which use `findLine` internally, would also return wrong results when using the boundary values.
>
> This patch mainly fixes `DiagnosticSource#findLine(N)` by using the following code.
>
>
> - return bp <= bufLen;
> + return bp < bufLen;
>
>
> A corresponding test `DiagnosticSourceTest.java` is added. Then, the usages of `getLineNumber`, `getColumnNumber` and `getLine` need to revised. And two existing tests need to be adjusted.
>
> Thank you for taking the time to review.
>
> Best Regards,
> --- Guoxiong
This pull request has been closed without being integrated.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3899
More information about the compiler-dev
mailing list