users@jsr311.java.net

Re: Valid paramer types and exception handling

From: Sergey Beryozkin <sergey.beryozkin_at_progress.com>
Date: Thu, 15 Jan 2009 10:29:17 -0000

Hi,
>>
>>> 2. Some Java types such as java.util.UUID have no valueOf(String) but have fromString(String) method instead. Would it make
>>> sense to have such methods evaluated too ?
>>>
>> Yes, that would also get round an issue with Enum where you can't override the valueOf method. I'll add this to the maintenance
>> release unless there are objections ?
>>
>
> Need to define precedence if fromString and valueOf are both present, which if we want to support enum means that fromString
> takes precedence over valueOf, which could break backwards compatibility if there are any, which i doubt there are, existing
> applications with classes that have both methods defined.
>
>
I did some experiments - checking if a given paramere class is enum lets to preserve the original precedence and change it only if
it's enum - that's, check fromString() first. In some (rare) cases where enum.valueOf() is expected to be called, a simple
delegation from fromString() would do the trick...

Cheers, Sergey