• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

throwing exception from finally block (try-finally clause without catch block)

 
Gasan Guseynov
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.

Here is the code example:



And my question is: what's happening with "e" exception? It seems that jvm completely forgot about it.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's one way of describing it. As you found out, the exception thrown in the finally block replaces the exception thrown in the try block. There can only be one exception thrown by a method, of course, so it's necessary to choose one. The choice is: the last one thrown.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a result, most people consider it very bad style to throw an exception -- or allow one to be thrown -- from a finally block.
 
Gasan Guseynov
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks all. It's very usefull information.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic