Request for Review: 7116914 (Miscellaneous warnings (sun.text))

Masayoshi Okutsu masayoshi.okutsu at oracle.com
Sun Dec 4 20:47:30 UTC 2011


We know serialVersionUID is useless for this case. But we decided to add
it, which is the standard fix, in order to eliminate the warning
message. I think serialization compatibility of anonymous inner classes
is another issue.

Thanks,
Masayoshi

On 2011/12/02 13:53, Stuart Marks wrote:
> On 12/1/11 11:51 PM, Yuka Kamiya wrote:
>> Hello,
>>
>> Could someone please review this fix?
>>
>> http://cr.openjdk.java.net/~peytoia/7116914/webrev.00/
>>
>> Some warnings are still issued even after this fix, and that's intentional.
>> I'd like to solve them in another way rather than using @SuppressWarnings("deprecation") in the future.
>>
>> The original number of warnings in this area was 70. Now 16.
> Hi Yuka,
>
> I wanted to ask about this bit of code in BidiBase.java:
>
> 3492         return new AttributedCharacterIterator.Attribute(name) {
> 3493             static final long serialVersionUID = -4899048055171307694L;
> 3494         };
>
> This is defining a serialVersionUID for an anonymous inner class. Serialization
> of anonymous classes is quite problematic. Among the problems is that anonymous
> classes have generated names that aren't specified. In this case the name is
> sun.text.bidi.BidiBase$TextAttributeConstants$1 which appears to be where you
> got the UID value. Unfortunately a different compiler might assign a different
> name. Or if this file is modified to use another anonymous class, this class
> might get a suffix of $2 (even if the same compiler is used). This means that
> it's pretty much impossible to guarantee serialization compatibility of
> anonymous classes.
>
> (Thanks to Joe Darcy, who explained this to me just yesterday.)
>
> You probably added a serialVersionUID because the compiler issued a warning
> about the lack of one. :-) In this case I think what makes the most sense is
> simply to suppress the warning.
>
> Actually the original code is a little odd, as it returns an instance of an
> anonymous subclass of AttributedCharacterIterator.Attribute, instead of an
> instance of AttributedCharacterIterator.Attribute itself. I don't if this is
> right or wrong.
>
> s'marks
>



More information about the core-libs-dev mailing list