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

An instance initializer in an anonymous class can't throw checked exceptions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • tools
    • generic
    • generic



      Name: igT44549 Date: 02/09/99


      import java.io.*;

      class C1 {
        void f() throws IOException {
                  Object o = new Object() {
                    {
                        x.readByte();
                    }
               };
            }

            DataInput x;
      }

      won't compile under JDK 1.2 as it objects to the exception thrown by
      x.readByte().

      The JDK 1.1 spec I have says:
      "An instance initializer in an anonymous class can throw any exceptions."
      (Review ID: 48957)
      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            iris Iris Clark
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: