Re: Making enum hashcodes consistent across JVM's

2022-03-17 Thread dfranken . jdk
Hi, Our use case is that we have different instances of an application running in a cloud environment and a precomputed hash code is used downstream to see if object instances generated in different application instances are the same or not. An enum was later added to our model which caused the

Making enum hashcodes consistent across JVM's

2022-03-17 Thread dfranken . jdk
Dear all, Currently enums do not have a well-defined hashCode() implementation so they defer to Object.hashCode() which just uses an internal mechanism to determine the hashcode, likely based on the object's place in the heap. This may confuse a lot of developers as other classes such as String

Some possible enhancements for java.time.Duration?

2021-06-15 Thread dfranken . jdk
Dear readers, I think java.time.Duration is a pretty useful class and after having to work a lot with it, I recognized there might be some enhancements we could make (where 'enhancement' is a subjective term of course). For instance: Comparison -- boolean isGreaterThan(Duration

Some questions about String interning for primitives

2021-06-03 Thread dfranken . jdk
Dear readers, Apologies in advance if these questions have been asked and discussed before or if they are on the wrong mailing list, maybe they are more suited for project Valhalla, I'm not sure. I was wondering if it would be possible / feasible to intern primitive values and byte arrays and

Re: [External] : Re: ReversibleCollection proposal

2021-05-20 Thread dfranken . jdk
Dear Brian, I understand this would be a massive undertaking. Still, the date-time library was a mess before Java 8 and it has been rewritten and found its way to most other libraries. So while I understand this isn't going to be done any time soon, my only question was whether it had been

Re: [External] : Re: ReversibleCollection proposal

2021-05-14 Thread dfranken . jdk
In reading all of the messages in this discussion, it becomes clear to me that this is not a trivial change, because we are mostly hindered by the Collection API as it currently exists. Adding interfaces seems like the correct OOP way to do things, but it may hinder adoption, because we have to

Re: [External] : Re: ReversibleCollection proposal

2021-05-11 Thread dfranken . jdk
t; - Mail original ----- > > De: "dfranken jdk" > > À: "Remi Forax" , "Stuart Marks" > > > > Cc: "core-libs-dev" > > Envoyé: Dimanche 9 Mai 2021 12:13:58 > > Objet: Re: [External] : Re: ReversibleCollection proposa

Re: New convenience methods on Stream

2021-05-09 Thread dfranken . jdk
>From my own limited experience, I've seen .collect(Supplier) often when an explicitly mutable collection is needed, such as with ArrayList::new or HashSet::new. Even though you could in theory use Stream.toList() for the ArrayList version, I don't think this is advisable as toList isn't

Re: [External] : Re: ReversibleCollection proposal

2021-05-09 Thread dfranken . jdk
When I thought about Collection's role in the hierarchy, it seemed to me that 'Collection' is an interface for describing how elements are stored in a cardboard box (we can and and remove them) and that we might need a different, yet related, interface to describe how to retrieve the items from

Re: Why does Set.of disallow duplicate elements?

2021-02-01 Thread dfranken . jdk
ed in Optional (`Optional.of` and `Optional.ofNullable`) and > > providing `Set.of` and `Set.ofMaybeUnique` (better name needed - > > 'ofOptionallyUnique'?) - to which the implementation could just be > > `Set.copyOf(Arrays.asList(args))` (unless a more efficient path > > prove

Why does Set.of disallow duplicate elements?

2021-01-30 Thread dfranken . jdk
Dear users, While looking at the implementation of Set.of(...) I noticed that duplicate elements are not allowed, e.g. Set.of(1, 1) will throw an IllegalArgumentException. Why has it been decided to do this? My expectation was that duplicates would simply be removed. If I do for instance new