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

Able to override private method without any errors from the compiler, causing unexpected results.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P2 P2
    • 5.0u7
    • 5.0u7
    • tools
    • None
    • x86
    • linux_redhat_8.0

      javac fail to detect the following:

      ClassA{
          private int doRead();
      }

      ClassB extends ClassA{
          protected int doRead();
      }

      Once compiled, calling classB.doRead() gives unexpected results. See attachement for the implementation I used to discover the problem.

      Also tested using:

      [ja120114@localhost grizzly]$ java -version
      java version "1.6.0-beta2"
      Java(TM) SE Runtime Environment (build 1.6.0-beta2-b77

      Under

      [ja120114@localhost grizzly]$ uname -a
      Linux localhost.localdomain 2.4.20-18.8 #1 Thu May 29 07:40:27 EDT 2003 i686 i686 i386 GNU/Linux

            Unassigned Unassigned
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: