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

Evaluate exception handling in JDK 7 and later

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 7, 8, 9
    • tools

      this code compiles since 7:
      public void m(){
              try{
                  System.out.println();
              } catch (Throwable e) {
                  throw e ;
              }
          }


      and this already not:
          public void m(){
              try{
                  if(false) throw new MyCheckedException();
              } catch (Throwable e) {
                  throw e ;
              }
          }
          public static class MyCheckedException extends Throwable {}

      javac checks try body for code which contains statements(methods) with checked exceptions, if they doesn't contain this . But Exception table still contains Throwable:


        public void m();
            stack=1, locals=2, args_size=1
               0: getstatic #5 // Field java/lang/System.out:Ljava/io/PrintStream;
               3: invokevirtual #6 // Method java/io/PrintStream.println:()V
               6: goto 12
               9: astore_1
              10: aload_1
              11: athrow
              12: return
            Exception table:
               from to target type
                   0 6 9 Class java/lang/Throwable
            StackMapTable: number_of_entries = 2
              frame_type = 73 /* same_locals_1_stack_item */
                stack = [ class java/lang/Throwable ]
              frame_type = 2 /* same */



            lpriima Lev Priima
            shadowbug Shadow Bug
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: