RFR: JDK-8243557: Inconvenient span for multi-catch error diagnostics

Jan Lahoda jan.lahoda at oracle.com
Fri Apr 24 15:38:08 UTC 2020


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 kulla-dev mailing list