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

scope of protected keyword

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.2.0
    • specification
    • generic
    • generic



      Name: rm29839 Date: 04/30/98


      protected presently has both package scope as well as allowing sub-classes
      access to the member. This is almost like package scope, which is the default. It
      allows anyone to access protected members if they just put a package statement
      in their code. We as OO programmers definitely need a protected that *only* allows
      sub-classes to access protected members, just like in C++. I understand that
      allowing package scope for protected memberswas necessary before there were
       inner classes, but now it is now it is no longer needed. As far as breaking
      existing code, a deprecation warning could be issued when protected members
      are accessed outside of sub-classes, and this then could become an error later
      in another version. I'm sure that this "feature" was used very little, and when it
      was used, it was used mostly to gain "illegitimate" access to protected members
      in classes that the author didn't write (without sub-classing).

      This is a very important issue for an OO language and breaks the encapsulation
      of classes
      (Review ID: 27976)
      ======================================================================

            gbrachasunw Gilad Bracha (Inactive)
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: