JAVA directly goes to finally or exits because it does not pass Catch (Exception e ).

Source: Internet
Author: User

JAVA directly goes to finally or exits because it does not pass Catch (Exception e ).
Today I encountered a very strange problem! When writing a Hadoop program! A new object! The program directly runs into the finally code block! The Exception in Catch is not executed either. Configuration configuration = new Configuration (); I have been wondering for a long time! Go to the Hadoop source code! The new object does not perform any operations, but some normal values are assigned! Later I found it online for a long time. It turned out to be Throwable! Exception is a subclass of Throwable, so it cannot be captured. The error message can be printed only when Throwable is captured! The original reason is that there is a static variable in the Hadoop Configuration class. When the ClassLoader loads the class, an exception occurs: private static final Log = LogFactory. getLog (Configuration. class); my error is very retarded, just because I didn't add the common-logging package! I believe that this kind of thing rarely happens! However, if we encounter this problem today, we should consider it as a lesson, so that those who have such questions can be solved! So in the future, do not think that Catch (Exception e) is even if everything is done, throwable is the ultimate BOSS! Why Throwable instead of Exception is thrown here? I have never found any reason! Which of the following is the hope! Thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.