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

protected classes and extending the Java Class Library

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.4, 1.1.5
    • core-libs
    • generic
    • generic



      Name: diC59631 Date: 06/04/98


      There are two classes in java.net, SocketInputStream and PlainSocketImpl which are packaged scoped. As such, they cannot be extended nor instantiated. This makes adding simply extensions very difficult. These two classes must be replaced in their entirety even if only small changes are needed to enhance the functionally; or the extensions are coded to be in the java.net package which violates the JLS package name rules (6.8.1). In order the take full advantage of the OO-ness of Java Classes, it might suggest that the language be extended to include "protected" as a class modifier. This could help both the package designer and the users accomplish their goals in a straight forward and obvious manner.

      Although, at least in the above case, these two classes could be declared as "public", add declared "protected" constructors and change the methods to be "protected". This would allow their being extended without undue exposure when used by the end-application user. The extension writer could use the bulk of the standard functionality relying on future enhancements and fixes in java.net to show through (excepted for the overridden methods). This would be preferrable over replicated large amounts of function which could become fragile over time.
      (Review ID: 24473)
      ======================================================================

            Unassigned Unassigned
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: