Skip to content

Seemingly puzzling exception handling behavior that appears sensitive to try block content #3443

Answered by srikanth-sankaran
laeubi asked this question in Q&A
Discussion options

You must be logged in to vote

Perhaps the title should read " ... depending on try block content ..." ??

Please always provide proper code with imports, class headers and such 😧 - Thanks!

ECJ behavior compares well with Javac 23 😄

Compilers actually track what exceptions may be raised by the try block, so can speak of "sharper" types -- that explains the puzzle.

I would say there is some mild surprise with the quick fixed added throws clause, although it is not a correctness issue and perhaps a long standing behavior.

There is some surprise why the catch block wouldn't be warned about in the very first case - but given bother compilers agree there is some arcane provision in the spec that calls for it, I would daresay

I…

Replies: 8 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by laeubi
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jukzi
Comment options

jukzi Dec 12, 2024
Collaborator

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #3441 on December 12, 2024 09:08.