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

inherited private method is considered an implementation of interface method

XMLWordPrintable

    • hopper
    • x86
    • windows_2000
    • Verified



      Name: gm110360 Date: 02/21/2002


      FULL PRODUCT VERSION :
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      FULL OPERATING SYSTEM VERSION :

      Microsoft Windows 2000 [Version 5.00.2195]



      EXTRA RELEVANT SYSTEM CONFIGURATION :

               


      A DESCRIPTION OF THE PROBLEM :
      The code below is considered erroneous by javac:
      The error message is:
      foo() in C1 cannot implement foo() in I; attempting to
      assign weaker access privileges; was public
      abstract class C2 extends C1 implements I {
               ^
      1 error

      -----------------------------------------------------------
      The class C1 is not implementing interface I, but its
      subclass is. However, the method in C1 is private, and
      should thus not have anything to to with it.
      Variant:
      Change C2 to:
      class C2 extends C1 implements I {
        public void foo() {

        }
      }

      i.e implementing the method.
      This code compiles.

      Another variant:
      C2 as the original, i.e. abstract,
      but adding one more class:

      class C3 extends C2 {
         public void foo() {

        }
      }

      Try to compile it - and there's the same error again.




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Copy the code into a file
      2. Compile the code


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The expected result is no errors.

      The actual result is one error (see above).

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      C:\develop\slask>javac ChangeAccess.java
      ChangeAccess.java:9: foo() in C1 cannot implement foo() in I; attempting to
      assign weaker access privileges; was public
      abstract class C2 extends C1 implements I {
               ^
      1 error

      C:\develop\slask>





      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      interface I {
        public void foo();
      }

      class C1 {
        private void foo(){}
      }

      abstract class C2 extends C1 implements I {

      }


      ---------- END SOURCE ----------
      (Review ID: 139163)
      ======================================================================

            gafter Neal Gafter (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: