Bug 119852 - unhandled exceptions sometimes not flagged as an error
Summary: unhandled exceptions sometimes not flagged as an error
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M3   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-08 07:55 EST by J.F.Lanting CLA
Modified: 2005-12-12 05:09 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description J.F.Lanting CLA 2005-12-08 07:55:23 EST
See this simple source:

   public static void main(String[] argv)
   {
      a();
      b(1);
      c(2);
   }
   
   public static void a()
   {
      int i = 0;
      i = Integer.parseInt("12345") + i; // May throw NumberFormatException.
   }
   
   public static void b(int k)
   {
      if(k < 0)
      {
         throw new NumberFormatException("Bad");
      }
   }
   
   public static void c(int k)
   {
      if(k < 0)
      {
         throw new Exception("Bad");
      }
   }

For some reason only method 'c' is flagged for an unhandled Exception.

;JOOP!
Comment 1 Philipe Mulet CLA 2005-12-12 05:09:14 EST
NumberFormatException inherits from RuntimeException and thus is unchecked, which means the compiler doesn't need to complain when uncaught.
This behavior is described in the Java language specification.