RFR: JDK-8243557: Inconvenient span for multi-catch error diagnostics
Vicente Romero
vicente.romero at oracle.com
Thu Apr 30 14:14:39 UTC 2020
looks good,
Vicente
On 4/24/20 11:38 AM, Jan Lahoda wrote:
> Hi,
>
> A very small tweak to diagnostic spans. In some cases, errors for
> multi-catches don't have a very nice spans. Like for example in the
> following case shown by JShell:
>
> jshell> try {
> ...> } catch (IllegalStateException | IOException ex) {}
> | Error:
> | exception java.io.IOException is never thrown in body of
> corresponding try statement
> | } catch (IllegalStateException | IOException ex) {}
> | ^-----------------------------------------------^
>
>
> underlining the whole catch clause feels unnecessary - the issue is
> only in IOException.
>
> With the proposed patch, the span is much more precise:
> jshell> try {
> ...> } catch (IllegalStateException | IOException ex) {}
> | Error:
> | exception java.io.IOException is never thrown in body of
> corresponding try statement
> | } catch (IllegalStateException | IOException ex) {}
> | ^---------^
>
>
> Webrev: http://cr.openjdk.java.net/~jlahoda/8243557/webrev.00/
> JBS: https://bugs.openjdk.java.net/browse/JDK-8243557
>
> How does this look?
>
> Thanks,
> Jan
More information about the compiler-dev
mailing list