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

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 1.2.0
    • Component/s: 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)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: