diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java index a8d6076c04a3..520586c4db6f 100644 --- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java +++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java @@ -16,6 +16,7 @@ package com.google.common.util.concurrent; +import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; @@ -23,6 +24,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Range; import com.google.common.collect.Sets; +import com.google.common.primitives.Ints; import com.google.common.util.concurrent.internal.InternalFutureFailureAccess; import java.util.ArrayList; import java.util.Arrays; @@ -293,6 +295,13 @@ public String pendingToString() { @SuppressWarnings({"DeprecatedThreadMethods", "ThreadPriorityCheck"}) @AndroidIncompatible // Thread.suspend public void testToString_delayedTimeout() throws Exception { + Integer javaVersion = Ints.tryParse(JAVA_SPECIFICATION_VERSION.value()); + // Parsing to an integer might fail because Java 8 returns "1.8" instead of "8." + // We can continue if it's 1.8, and we can continue if it's an integer in [9, 20). + if (javaVersion != null && javaVersion >= 20) { + // TODO(b/261217224): Make this test work under newer JDKs. + return; + } TimedWaiterThread thread = new TimedWaiterThread(new AbstractFuture() {}, 2, TimeUnit.SECONDS); thread.start(); diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java index a8d6076c04a3..520586c4db6f 100644 --- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java @@ -16,6 +16,7 @@ package com.google.common.util.concurrent; +import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; @@ -23,6 +24,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Range; import com.google.common.collect.Sets; +import com.google.common.primitives.Ints; import com.google.common.util.concurrent.internal.InternalFutureFailureAccess; import java.util.ArrayList; import java.util.Arrays; @@ -293,6 +295,13 @@ public String pendingToString() { @SuppressWarnings({"DeprecatedThreadMethods", "ThreadPriorityCheck"}) @AndroidIncompatible // Thread.suspend public void testToString_delayedTimeout() throws Exception { + Integer javaVersion = Ints.tryParse(JAVA_SPECIFICATION_VERSION.value()); + // Parsing to an integer might fail because Java 8 returns "1.8" instead of "8." + // We can continue if it's 1.8, and we can continue if it's an integer in [9, 20). + if (javaVersion != null && javaVersion >= 20) { + // TODO(b/261217224): Make this test work under newer JDKs. + return; + } TimedWaiterThread thread = new TimedWaiterThread(new AbstractFuture() {}, 2, TimeUnit.SECONDS); thread.start();