[ 
https://issues.apache.org/jira/browse/LUCENE-7796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15980147#comment-15980147
 ] 

Uwe Schindler edited comment on LUCENE-7796 at 4/22/17 10:40 PM:
-----------------------------------------------------------------

bq. It is based on JVM spec knowledge, not Java spec and it can lead to 
surprising code paths.

That's not true. It is misuse, but behavior is still expected. The same happens 
if you change a method to suddenly throw a checked Exception. Code compiled 
against old signature leads to no runtime or linkage errors. But it can still 
be surprising, because the code may throw a checked exception unexpected.

BTW: We have more rethrows in the expressions module. And there - please don't 
remove, it would break the expressions compiler. The reason why its there is: 
The ANTLR API needs to implement an interface that does not allow checked 
exceptions. But the code inside this interface needs to throw ParseExceptions, 
which are checked. So we need the rethrow hack... But the code is also safe, as 
the outer method declares the ParseException, so code calling the public 
compiler API will only see declared Exceptions: 
https://github.com/apache/lucene-solr/blob/master/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java#L298-L301,
 but code that calls the visitor declares the ParseException: 
https://github.com/apache/lucene-solr/blob/master/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java#L231


was (Author: thetaphi):
bq. It is based on JVM spec knowledge, not Java spec and it can lead to 
surprising code paths.

That's not true. It is misuse, but behavior is still expected. The same happens 
if you change a method to suddenly throw a checked Exception. Code compiled 
against old signature leads to no runtime or linkage errors. But it can still 
be surprising, because the code may throw a checked exception unexpected.

BTW: We have more rethrows in the expressions module. And there - please don't 
remove, it would break the expressions compiler.

> Make reThrow idiom declare RuntimeException return type so callers may use it 
> in a way that compiler knows subsequent code is unreachable
> -----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-7796
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7796
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Dawid Weiss
>            Assignee: Dawid Weiss
>            Priority: Trivial
>             Fix For: 6.x, master (7.0)
>
>
> A spinoff from LUCENE-7792: reThrow can be declared to return an unchecked 
> exception so that callers can choose to use {{throw reThrow(...)}} as an 
> idiom to let the compiler know any subsequent code will be unreachable.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to