<Swing Dev> JDK 9 RFR of JDK-8055059: JDK9b22 public API exposes package private classes, take 2
Phil Race
philip.race at oracle.com
Mon Jan 12 17:30:14 UTC 2015
+1
-phil.
On 1/12/2015 1:13 AM, Sergey Bylokhov wrote:
> Hi, Joe.
> The fix looks good.
>
> On 10.01.2015 3:23, Joseph D. Darcy wrote:
>> Hello,
>>
>> The previously proposed fix for
>>
>> JDK-8055059: JDK9b22 public API exposes package private classes
>>
>> was rejected during code review:
>>
>> http://mail.openjdk.java.net/pipermail/swing-dev/2014-August/003829.html
>> http://mail.openjdk.java.net/pipermail/swing-dev/2014-August/003830.html
>>
>> Here is a new proposed fix that reverts the Vector<UndoPosRef>
>> variable and values to a raw Vector to avoid exposing the UndoPosRef
>> types more widely:
>>
>> http://cr.openjdk.java.net/~darcy/8055059.1/
>>
>> Patch inline below.
>>
>> The code as amended still compiles without rawtypes or unchecked
>> warnings.
>>
>> Thanks,
>>
>> -Joe
>>
>> ---
>> 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 >= 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 {
>>
>
>
More information about the swing-dev
mailing list