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

unclear diagnostic when anon class fails to override abstract pkg private method

    XMLWordPrintable

Details

    • mantis
    • x86
    • linux

    Description



      Name: nt126004 Date: 05/16/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)


      FULL OPERATING SYSTEM VERSION :

      glibc-2.2.4-25mdk
      Linux [internal name] 2.4.18-6mdk #1 Fri Mar 15 02:59:08 CET 2002 i686 unknown

      A DESCRIPTION OF THE PROBLEM :
      This is at least an inaccurate error message in the
      compiler. It may also be a bug, preventing certain
      things from compiling.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just save the two files and compile.


      ERROR MESSAGES THAT APPEAR :

      The error message

      > (926) javac -d dest *.java
      > BBB.java:9: <anonymous buggy2.BBB$1> should be declared
      > abstract; it does not define mm() in buggy1.AAA
      > int mm() { return 3; }
      > ^
      > 1 error

      is definitely not true. The fix is to change the method signature in AAA
      to be
      public abstract int mm();

      The compiler should generate a more helpful or informative message.

      This bug can be reproduced always.

      ------ BEGIN SOURCE -------
      There are two files.


      //// This is file AAA.java
      package buggy1;
      public abstract class AAA {
          abstract int mm();
      }


      //// This is file BBB.java
      package buggy2;
      import buggy1.AAA;

      public class BBB {
          public void main() {
      AAA aa = new AAA () {
      int mm() { return 3; }
      };
      System.out.println("bbb");
          }
      }
      //// End of BBB.java
      ------- END SOURCE --------

      CUSTOMER WORKAROUND :
      Make the method public, or put the two classes in the same package.
      (Review ID: 146573)
      ======================================================================

      Attachments

        Activity

          People

            gafter Neal Gafter
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: