-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Java 9 Stream APIs #9837
Add Java 9 Stream APIs #9837
Conversation
https://github.com/niloc132/gwt/actions/runs/5315644262/jobs/9624263435 shows successful build in all three tested Java runtime versions. |
user/super/com/google/gwt/emul/java/util/stream/Collectors.java
Outdated
Show resolved
Hide resolved
user/super/com/google/gwt/emul/java/util/stream/DoubleStream.java
Outdated
Show resolved
Hide resolved
Note especially that this avoids an extra lambda, saving a extra type and makeFunction call
user/super/com/google/gwt/emul/java/util/stream/DoubleStream.java
Outdated
Show resolved
Hide resolved
Also moved newly created test for old behavior to java8 class
@zbynek so it seems that Java8 has the same bug that GWT had here previously, so my new test above is failing in legacy dev mode. import java.util.stream.DoubleStream;
import java.util.Arrays;
class Test {
public static void main(String[] args) {
int[] callCount = { 0 };
double[] values = DoubleStream.iterate(0, val -> {
callCount[0]++;
return val + 1;
}).limit(5).toArray();
System.out.println(callCount[0]);
System.out.println(Arrays.toString(values));
}
} In Java 11+, this results in
But in Java 8 (both my local copy and the build that the GHA runner is using), this yields:
Excitingly, Java 8 only has this bug for IntStream, DoubleStream, and LongStream, just plain Stream has the same behavior in 8 and 11/17: import java.util.stream.Stream;
import java.util.Arrays;
class Test {
public static void main(String[] args) {
int[] callCount = { 0 };
Integer[] values = Stream.iterate(0, val -> {
callCount[0]++;
return val + 1;
}).limit(5).toArray(Integer[]::new);
System.out.println(callCount[0]);
System.out.println(Arrays.toString(values));
}
}
|
Note that these would pass in legacy dev mode in Java 11/17, but we don't run legacy dev mode tests for those JVMs for a variety of reasons.
https://github.com/niloc132/gwt/actions/runs/6792333097 All current tests pass. |
Partial #9547