Bug 119852

Summary: unhandled exceptions sometimes not flagged as an error
Product: [Eclipse Project] JDT Reporter: J.F.Lanting <J.F.Lanting>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.2 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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.