RFR : 8016446 : (m) Add override forEach/replaceAll to HashMap, Hashtable, IdentityHashMap, WeakHashMap, TreeMap
David Chase
david.r.chase at oracle.com
Fri Jun 14 13:23:46 UTC 2013
On 2013-06-14, at 8:41 AM, Remi Forax <forax at univ-mlv.fr> wrote:
> In the codes I was referring to, there was always a way to know that the remove was done at the end by example by knowing that the last element was a special sentinel or by using a counter.
> So is the following program bugged ?
>
> List<Integer> l = new ArrayList<>(Arrays.asList(1, 2, null));
> for (Integer i : l) {
> if (i == null) {
> l.set(l.size() - 1, 3); // change the last value to 3
> }
> }
There will come a time when it should be considered buggy, yes. Assume the future is parallel. Java's intricately specified serial legacy may cause problems, and if it gets to the point that "every good programmer knows" that the rule is to sprinkle parallel-parallel-parallel-parallel throughout their code, they may eventually wander off to find another language.
David
More information about the core-libs-dev
mailing list