Skip to content

Commit b15c23f

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Use most of the main AbstractFuture implementation from J2KT and from 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
1 parent 2dd82ad commit b15c23f

File tree

16 files changed

+1863
-1953
lines changed

16 files changed

+1863
-1953
lines changed

android/guava-testlib/src/com/google/common/testing/NullPointerTester.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import static com.google.common.base.Preconditions.checkArgument;
2020
import static com.google.common.base.Preconditions.checkNotNull;
2121
import static java.util.Arrays.stream;
22+
import static java.util.Objects.requireNonNull;
23+
import static java.util.stream.Stream.concat;
2224

2325
import com.google.common.annotations.GwtIncompatible;
2426
import com.google.common.annotations.J2ktIncompatible;
@@ -108,7 +110,9 @@ public NullPointerTester() {
108110
* versions of Java, and apparently Unsafe can cause SIGSEGV instead of NPE—almost as if it's
109111
* not safe.
110112
*/
111-
stream(AbstractFuture.class.getDeclaredMethods())
113+
concat(
114+
stream(AbstractFuture.class.getDeclaredMethods()),
115+
stream(requireNonNull(AbstractFuture.class.getSuperclass()).getDeclaredMethods()))
112116
.filter(
113117
m ->
114118
m.getName().equals("getDoneValue")

android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureFallbackAtomicHelperTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ private void runTestMethod(ClassLoader classLoader) throws Exception {
110110
private void checkHelperVersion(ClassLoader classLoader, String expectedHelperClassName)
111111
throws Exception {
112112
// Make sure we are actually running with the expected helper implementation
113-
Class<?> abstractFutureClass = classLoader.loadClass(AbstractFuture.class.getName());
114-
Field helperField = abstractFutureClass.getDeclaredField("ATOMIC_HELPER");
113+
Class<?> abstractFutureStateClass = classLoader.loadClass(AbstractFutureState.class.getName());
114+
Field helperField = abstractFutureStateClass.getDeclaredField("ATOMIC_HELPER");
115115
helperField.setAccessible(true);
116116
assertEquals(expectedHelperClassName, helperField.get(null).getClass().getSimpleName());
117117
}

android/guava-tests/test/com/google/common/util/concurrent/AggregateFutureStateFallbackAtomicHelperTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ private void runTestMethod(ClassLoader classLoader) throws Exception {
112112
private void checkHelperVersion(ClassLoader classLoader, String expectedHelperClassName)
113113
throws Exception {
114114
// Make sure we are actually running with the expected helper implementation
115-
Class<?> abstractFutureClass = classLoader.loadClass(AggregateFutureState.class.getName());
116-
Field helperField = abstractFutureClass.getDeclaredField("ATOMIC_HELPER");
115+
Class<?> abstractFutureStateClass = classLoader.loadClass(AggregateFutureState.class.getName());
116+
Field helperField = abstractFutureStateClass.getDeclaredField("ATOMIC_HELPER");
117117
helperField.setAccessible(true);
118118
assertEquals(expectedHelperClassName, helperField.get(null).getClass().getSimpleName());
119119
}

0 commit comments

Comments
 (0)