Skip to content

Commit

Permalink
Use most of the main AbstractFuture implementation from J2KT and fr…
Browse files Browse the repository at this point in the history
…om GWT/J2CL.

This CL introduces a superclass, `AbstractFutureState`, following the pattern of [`AggregateFutureState`](https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/AggregateFutureState.java). That superclass contains platform-specific operations.

Fixes #2934

RELNOTES=n/a
PiperOrigin-RevId: 729328833
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Feb 21, 2025
1 parent 2dd82ad commit b15c23f
Show file tree
Hide file tree
Showing 16 changed files with 1,863 additions and 1,953 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Arrays.stream;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Stream.concat;

import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
Expand Down Expand Up @@ -108,7 +110,9 @@ public NullPointerTester() {
* versions of Java, and apparently Unsafe can cause SIGSEGV instead of NPE—almost as if it's
* not safe.
*/
stream(AbstractFuture.class.getDeclaredMethods())
concat(
stream(AbstractFuture.class.getDeclaredMethods()),
stream(requireNonNull(AbstractFuture.class.getSuperclass()).getDeclaredMethods()))
.filter(
m ->
m.getName().equals("getDoneValue")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ private void runTestMethod(ClassLoader classLoader) throws Exception {
private void checkHelperVersion(ClassLoader classLoader, String expectedHelperClassName)
throws Exception {
// Make sure we are actually running with the expected helper implementation
Class<?> abstractFutureClass = classLoader.loadClass(AbstractFuture.class.getName());
Field helperField = abstractFutureClass.getDeclaredField("ATOMIC_HELPER");
Class<?> abstractFutureStateClass = classLoader.loadClass(AbstractFutureState.class.getName());
Field helperField = abstractFutureStateClass.getDeclaredField("ATOMIC_HELPER");
helperField.setAccessible(true);
assertEquals(expectedHelperClassName, helperField.get(null).getClass().getSimpleName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ private void runTestMethod(ClassLoader classLoader) throws Exception {
private void checkHelperVersion(ClassLoader classLoader, String expectedHelperClassName)
throws Exception {
// Make sure we are actually running with the expected helper implementation
Class<?> abstractFutureClass = classLoader.loadClass(AggregateFutureState.class.getName());
Field helperField = abstractFutureClass.getDeclaredField("ATOMIC_HELPER");
Class<?> abstractFutureStateClass = classLoader.loadClass(AggregateFutureState.class.getName());
Field helperField = abstractFutureStateClass.getDeclaredField("ATOMIC_HELPER");
helperField.setAccessible(true);
assertEquals(expectedHelperClassName, helperField.get(null).getClass().getSimpleName());
}
Expand Down
Loading

0 comments on commit b15c23f

Please sign in to comment.