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

Warning for return expression lost due to abrupt transfer of finally clause

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.1.3
    • tools
    • None
    • generic
    • solaris_2.5.1


      This kind of construct has been seen in several Modena testcases and
      I consider it a bug in those testcases, and in general. I wished that
      javac would detect it and print out an error or some kind of warning.

      class b {
          public static int f() {
              try {
                      return 5; /* <---- 5 is NEVER returned! */
              }
              finally {
                      return 6;
              }
          }
      }

      Without a return expression there appears to be no harm, or mis-understanding
      as to what is happening, but with a return expression the behavior is
      very very mis-leading... Consider it being even worse:

      class b {
          public static int f() {
            try {
              try {
                      return 5; /* <---- 5 is NEVER returned! */
              }
              finally {
                      return 6;
              }
            }
            finally {
                      return 7;
            }
          }
      }

      Now it never returns 5 or 6, yet those statements appear to be executed.

      Perhaps a

      warning: return expression lost due to abrupt transfer of finally clause

      ???

      -kto

      kelly.ohair@Eng 1997-10-24

            dstoutamsunw David Stoutamire (Inactive)
            ohair Kelly Ohair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: