RFR(m): 8139233u1 add initial compact immutable collection implementations
Stuart Marks
stuart.marks at oracle.com
Wed May 11 21:37:11 UTC 2016
Hi,
I agree with Stephen, using an enum here is overkill. :-)
The way I think about this is that the collection implementations and the
CollSer proxy are fairly closely coupled, so adding an enum here only makes this
coupling more obscure.
There's another wrinkle that I had slipped into the updated webrev. Only the low
order 8 bits of the flags field indicates the type of the collection. The high
order 24 bits are deliberately ignored by this implementation, so they can be
used by future implementations to indicate some variations on the basic types.
The 8/24 split is pretty much arbitrary. I'm not entirely sure how the 24 bits
might be used, but it's nice having some spare bits around, and it's simpler
than adding fields to future serialized forms.
Speaking of serialized form, note that I still need to specify the serialized
format. That's covered by JDK-8133977, forthcoming.
s'marks
On 5/9/16 12:17 PM, Remi Forax wrote:
> Hi Stephen,
> you may right :)
>
> First note that the Enum values are used as an ephemeral state, the serialized form still uses an integer as the original code.
> You can also note that the enum is not loaded if no immutable collection is serialized (because CollSer is not initialized).
> It's just a good old OOP trick that transforms a switch to a dispatch that will be used when de-serializing.
>
> In my opinion, if there are several other immutable collections (like the ordered set/map proposed by Stuart), the code with an enum is easier to modify that the current code, otherwise, as you said, it's an overkill.
>
> Rémi
>
> ----- Mail original -----
>> De: "Stephen Colebourne" <scolebourne at joda.org>
>> À: "core-libs-dev" <core-libs-dev at openjdk.java.net>
>> Envoyé: Lundi 9 Mai 2016 19:49:15
>> Objet: Re: RFR(m): 8139233u1 add initial compact immutable collection implementations
>>
>> On 9 May 2016 at 15:25, Remi Forax <forax at univ-mlv.fr> wrote:
>>> CollSer implementation can be improved to avoid the ugly switch/case by
>>> replacing the constant list by an enum,
>>
>> CollSer is modelled on JSR-310 code which uses an int. An enum would
>> be a huge overkill for this use case.
>>
>> Stephen
>>
More information about the core-libs-dev
mailing list