You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today, the generated code for lazy int returns the following, which will overflow silently for large sums.
private static final class IntSumProcedure implements IntProcedure
{
private int sum = 0;
@Override
public void value(int each)
{
this.sum += each;
}
public int getValue()
{
return this.sum;
}
}
This was a Project Loom code example in a test that I wrote that failed (using Java 20):
@Test
public void usingLoomWithEclipseCollectionsLazyAsParallel()
{
long sum = Interval.oneTo(2_000_000)
.toList()
.asParallel(Executors.newVirtualThreadPerTaskExecutor(), 2)
.sumOfInt(each -> each * 2);
long expected = IntInterval.oneTo(2_000_000).asLazy().collectInt(each -> each * 2).sum();
Assertions.assertEquals(expected, sum);
}
Expected :1387447424 Actual :4000002000000
A similar test could be written in Java 8 without using asParallel.
The text was updated successfully, but these errors were encountered:
Today, the generated code for lazy int returns the following, which will overflow silently for large sums.
https://github.com/eclipse/eclipse-collections/blob/master/eclipse-collections-code-generator/src/main/resources/impl/lazy/abstractLazyPrimitiveIterable.stg#L451
This was a Project Loom code example in a test that I wrote that failed (using Java 20):
Expected :1387447424
Actual :4000002000000
A similar test could be written in Java 8 without using
asParallel
.The text was updated successfully, but these errors were encountered: