Review request for java.text.** warning cleanup

John Rose john.r.rose at oracle.com
Fri Dec 2 14:19:48 PST 2011


On Dec 2, 2011, at 11:20 AM, Rémi Forax wrote:

> It seems you still use clone,
> you can't replace a call to clone with a call to a copy constructor because
> if Stack is subclassed, clone will work but not the copy constructor.

That's true in general, but this is private code with locally created Stack instances.

>> ../../../src/share/classes/java/text/AttributedString.java:420: error: incompatible types
>>         Vector<Attribute>  newRunAttributes[] = new Vector<?>[ARRAY_SIZE_INCREMENT];
>>                                                ^
>>   required: Vector<Attribute>[]
>>   found:    Vector<?>[]
> 
> Yes, you need to add a cast,
> 
> Vector<Attribute>[] newRunAttributes = (Vector<Attribute>[])new Vector<?>[ARRAY_SIZE_INCREMENT];

Yes.  As far as I can see, that's the "best practices" way to deal with array-of-generic.

> but if Java is reified in 1.9 as state the current plan, we will be in trouble.

If the best practices have to change, then we'll have to change that code again.  Or maybe the retrofit strategy will have to take account of the existing code idioms.  In any case, we'll cross that bridge when we get to it.  (Coping with reification in this case is a decision to make tomorrow, not today.)

-- John



More information about the jdk8-dev mailing list