Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 180633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:37:15+00:00 2026-05-11T14:37:15+00:00

I have a thread in which I catch all errors in a big, all-encompassing

  • 0

I have a thread in which I catch all errors in a big, all-encompassing catch block. I do this so that I can report any error, not just expected ones, in my application. My Runnable looks like this:

public final void run() {     try     {         System.out.println('Do things'); /* [1] */          doUnsafeThings();     }     catch (Throwable t)     {         System.out.println('Catch'); /* [2] */          recover();     }     finally     {         System.out.println('Finally'); /* [3] */     } } 

I would expect the NPE to be caught by the Throwable catch block. Instead, the output at [2] is not printed, and neither is [3]. The output at [1] is printed.

What I do get on the console, is this:

Uncaught exception java/lang/NullPointerException. 

What on earth is going on here?

For the court records, I’m using J2ME, and this is running in Sun’s WTK v2.5.2 emulator.

I’m tempted to put it down to JVM implementation dodginess but I can’t help feeling that I’m just missing something.

To clarify for the avoidance of doubt (Since the example code is obviously altered from my production code)

  • There is nothing outside of the try/catch/finally block in the run method.
  • There is a System.out.println at the start of each of those blocks – What follows those console statements should not matter.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:37:16+00:00Added an answer on May 11, 2026 at 2:37 pm

    The answer turns out that I’m an idiot. I’d explain what went wrong, but let’s just call it ‘one of those bugs’.

    I had momentarily forgotten that the thread that ran the runnable was a custom thread class (To get round some Nokia bugs). It called run() repeatedly between calls to a canWait() method.

    The canWait method was responsible for the failure, and run wasn’t failing at all. To top it off, I have console-blindness and completely but accidentally misquoted the sequence of events in my question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my C# program, I have a thread that represents a running test, which
I have a Java application in which user can give any executable file (.exe)
I have been looking all over MSDN and can't find a reason why Thread
I have thread exception handler which saves the exception stack trace and should close
I have one std::list<> container and these threads: One writer thread which adds elements
I'm working on a thread library which implement user level threads (i have something
I have a class which is not thread safe: class Foo { /* Abstract
I have a layered application in Java which has a multi thread data access
Using POSIX threads & C++, I have an Insert operation which can only be
I have one thread that writes results into a Queue. In another thread (GUI),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.