RFR: Add value-type notice to java.time classes

roger riggs roger.riggs at oracle.com
Thu Dec 5 14:24:57 UTC 2013


Hi Stephen,

On 12/5/2013 6:04 AM, Stephen Colebourne wrote:
> Pretty much looks good.
>
> However, I notice that the equals, hashCode and toString methods of
> the 4 calendar specific date classes are inherited rather than
> written. Without additional spec, I'm not sure that they can claim to
> be value types. Adding the 12 Javadocs should be relatively easy.
I considered that the behavior of these methods meet the criteria, not 
the existence
or location of the declaration/implementation.
>
> JapaneseEra should also be a value type, but it needs Javadoc and an
> implementation of equals and hashCode that check state.
Could be, but they are considered Singletons, see below.
>
> The chronology classes are potential value types, but as they are
> generally singletons, perhaps it matters less.

I considered the term Singleton implies an identity relationship.
The == operator is commonly used with singletons (not equals).
So unless the language was modified to remove the term singleton I did not
think they qualified as value types; similarly for all of the enums.

Roger





More information about the core-libs-dev mailing list