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

compilation fails on anonymous inner class implementing > 1 abstract methods

XMLWordPrintable

    • sparc
    • solaris_2.5.1



      Name: laC46010 Date: 05/08/97



      JDK1.1.2D compiler fails to compile the following example
      taken directly from the Inner Classes specification.
      (Note that this code can't be compiled with both JDK1.1, JDK1.1.1
      compilers as well).

      It looks like the bug appears only when anonymous inner class
      implements MORE than ONE abstract method. It is true for both
      interfaces and abstract classes used as super class of the
      anonymous class. If a base interface (or abstract class) has only
      one abstract method, compilation succeeds.

      --------------------icls00601.java----------------------
      import java.util.Enumeration;

      class a {
      Enumeration myEnumerate(final Object array[]) {
      return new Enumeration() {
      int count = 0;
      public boolean hasMoreElements()
      { return count < array.length; }
      public Object nextElemnt()
      { return array[count++]; }
      };
      }
      }
      ---------------------------------------------------------

      producing the following output:

      icls00601.java:5: interface java.util.Enumeration is an abstract class. It can't be instantiated.
      return new Enumeration() {
      ^
      icls00601.java:5: local class a. 1 must be declared abstract and not final. It does not define java.lang.Object nextElement() from interface java.util.Enumeration.
      return new Enumeration() {
      ^
      2 errors

      ======================================================================

            dstoutamsunw David Stoutamire (Inactive)
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: