Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1224280

Incorrect warning about exception not caught

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P5
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.0
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      1.0beta
    • CPU:
      sparc
    • OS:
      solaris_2.4
    • Verification:
      Not verified

      Description

      The following code generates this compiler warning:
      finallyBug.java:12: Warning: Exception java.lang.InterruptedException must be caught, or it must be declared in throws clause of this method.
      t.join();
      ^
      1 warning

      This warning is wrong because the exception cannot be propagated: the
      try{...}finally{return;} surrounding t.wait() effectively catches and discards
      all exceptions.

          public
          class finallyBug extends java.applet.Applet implements Runnable{
      boolean v;
      public void run(){
      v = true;
      }
      static boolean foo( finallyBug b ){
      try{
      Thread t;
      t = new Thread( b );
      t.start();
      t.join();
      } finally {
      return b.v;
      }
      }
          
      public finallyBug(){v = false;}
      public void init(){
      System.out.println("foo() "+(foo( this )?"succeeded":"failed") );
      }
          
      public static void main( String ignore[] ){
      System.out.println("foo() "+(foo( new finallyBug() )?"succeeded":"failed") );
      }
          
          }
          

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fyellinsunw Frank Yellin (Inactive)
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: