Uploaded image for project: 'CCC Migration Project'
  1. CCC Migration Project
  2. CCC-8055059

JDK9b22 public API exposes package private classes

    XMLWordPrintable

    Details

    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Restoring previous raw type usage in a few caues.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Revert to using raw types in some parts of javax.swing.text to avoid exposing package-private types.

      Problem

      The generification of swing exposed some package-private types as the bounds of type variables on non-private methods. Such types should not be exposed.

      Solution

      After due consideration of the alternatives, revert to using raw types for the parameters and return types in question.

      Specification

      --- old/src/java.desktop/share/classes/javax/swing/text/GapContent.java 2015-01-09 14:48:54.394781325 -0800
      +++ new/src/java.desktop/share/classes/javax/swing/text/GapContent.java 2015-01-09 14:48:54.122781325 -0800
      @@ -710,8 +710,9 @@
            * @param length the length >= 0
            * @return the set of instances
            */
      -    protected Vector<UndoPosRef> getPositionsInRange(Vector<UndoPosRef> v,
      -                                                     int offset, int length) {
      +    @SuppressWarnings({"rawtypes", "unchecked"}) // UndoPosRef type cannot be exposed
      +    protected Vector getPositionsInRange(Vector v,
      +                                         int offset, int length) {
               int endOffset = offset + length;
               int startIndex;
               int endIndex;
      @@ -758,7 +759,8 @@
            *
            * @param positions the UndoPosRef instances to reset
            */
      -    protected void updateUndoPositions(Vector<UndoPosRef> positions, int offset,
      +    @SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
      +    protected void updateUndoPositions(Vector positions, int offset,
                                              int length) {
               // Find the indexs of the end points.
               int endOffset = offset + length;
      @@ -775,7 +777,7 @@
       
               // Reset the location of the refenences.
               for(int counter = positions.size() - 1; counter >= 0; counter--) {
      -            UndoPosRef ref = positions.elementAt(counter);
      +            UndoPosRef ref = (UndoPosRef)positions.elementAt(counter);
                   ref.resetLocation(endOffset, g1);
               }
               // We have to resort the marks in the range startIndex to endIndex.
      @@ -902,7 +904,8 @@
               protected String string;
               /** An array of instances of UndoPosRef for the Positions in the
                * range that was removed, valid after undo. */
      -        protected Vector<UndoPosRef> posRefs;
      +        @SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
      +        protected Vector posRefs;
           } // GapContent.InsertUndo
       
       
      @@ -911,6 +914,7 @@
            */
           @SuppressWarnings("serial") // JDK-implementation class
           class RemoveUndo extends AbstractUndoableEdit {
      +        @SuppressWarnings("unchecked")
               protected RemoveUndo(int offset, String string) {
                   super();
                   this.offset = offset;
      @@ -934,6 +938,7 @@
                   }
               }
       
      +        @SuppressWarnings("unchecked")
               public void redo() throws CannotRedoException {
                   super.redo();
                   try {
      --- old/src/java.desktop/share/classes/javax/swing/text/StringContent.java      2015-01-09 14:48:55.178781325 -0800
      +++ new/src/java.desktop/share/classes/javax/swing/text/StringContent.java      2015-01-09 14:48:54.918781325 -0800
      @@ -271,11 +271,12 @@
            * @param length the length &gt;= 0
            * @return the set of instances
            */
      -    protected Vector<UndoPosRef> getPositionsInRange(Vector<UndoPosRef> v, int offset,
      -                                                      int length) {
      +    @SuppressWarnings({"rawtypes", "unchecked"}) // UndoPosRef type cannot be exposed
      +    protected Vector getPositionsInRange(Vector v, int offset,
      +                                         int length) {
               int n = marks.size();
               int end = offset + length;
      -        Vector<UndoPosRef> placeIn = (v == null) ? new Vector<>() : v;
      +        Vector placeIn = (v == null) ? new Vector() : v;
               for (int i = 0; i < n; i++) {
                   PosRec mark = marks.elementAt(i);
                   if (mark.unused) {
      @@ -298,9 +299,10 @@
            *
            * @param positions the positions of the instances
            */
      -    protected void updateUndoPositions(Vector<UndoPosRef> positions) {
      +    @SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
      +    protected void updateUndoPositions(Vector positions) {
               for(int counter = positions.size() - 1; counter >= 0; counter--) {
      -            UndoPosRef ref = positions.elementAt(counter);
      +            UndoPosRef ref = (UndoPosRef)positions.elementAt(counter);
                   // Check if the Position is still valid.
                   if(ref.rec.unused) {
                       positions.removeElementAt(counter);
      @@ -437,7 +439,8 @@
               protected String string;
               // An array of instances of UndoPosRef for the Positions in the
               // range that was removed, valid after undo.
      -        protected Vector<UndoPosRef> posRefs;
      +        @SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
      +        protected Vector posRefs;
           }
       
       
      @@ -445,6 +448,7 @@
            * UndoableEdit created for removes.
            */
           class RemoveUndo extends AbstractUndoableEdit {
      +        @SuppressWarnings("unchecked")
               protected RemoveUndo(int offset, String string) {
                   super();
                   this.offset = offset;
      @@ -471,6 +475,7 @@
                   }
               }
       
      +        @SuppressWarnings("unchecked")
               public void redo() throws CannotRedoException {
                   super.redo();
                   try {

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darcy Joe Darcy
              Reporter:
              darcy Joe Darcy
              Reviewed By:
              Sergey Bylokhov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: