Skip to content

Commit bc60bad

Browse files
Merge branch 'master' into test/map-entryset-stream-spliterator
2 parents e219ab5 + e6e0259 commit bc60bad

File tree

128 files changed

+448
-328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+448
-328
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static final class OneSizeTestSuiteBuilder<T, E>
126126
private final List<Class<? extends AbstractTester>> testers;
127127

128128
@SuppressWarnings("rawtypes") // class literals
129-
public OneSizeTestSuiteBuilder(List<Class<? extends AbstractTester>> testers) {
129+
OneSizeTestSuiteBuilder(List<Class<? extends AbstractTester>> testers) {
130130
this.testers = testers;
131131
}
132132

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ private static class AsMapGenerator<K, V, M extends Multimap<K, V>>
314314
implements TestMapGenerator<K, Collection<V>>, DerivedGenerator {
315315
private final OneSizeTestContainerGenerator<M, Entry<K, V>> multimapGenerator;
316316

317-
public AsMapGenerator(OneSizeTestContainerGenerator<M, Entry<K, V>> multimapGenerator) {
317+
AsMapGenerator(OneSizeTestContainerGenerator<M, Entry<K, V>> multimapGenerator) {
318318
this.multimapGenerator = multimapGenerator;
319319
}
320320

@@ -638,8 +638,7 @@ private static class ReserializedMultimapGenerator<K, V, M extends Multimap<K, V
638638
implements TestMultimapGenerator<K, V, M> {
639639
private final OneSizeTestContainerGenerator<M, Entry<K, V>> multimapGenerator;
640640

641-
public ReserializedMultimapGenerator(
642-
OneSizeTestContainerGenerator<M, Entry<K, V>> multimapGenerator) {
641+
ReserializedMultimapGenerator(OneSizeTestContainerGenerator<M, Entry<K, V>> multimapGenerator) {
643642
this.multimapGenerator = multimapGenerator;
644643
}
645644

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ public List<Integer> order(List<Integer> insertionOrder) {
412412

413413
private abstract static class AbstractContiguousSetGenerator
414414
extends TestIntegerSortedSetGenerator {
415-
protected final ContiguousSet<Integer> checkedCreate(SortedSet<Integer> elementsSet) {
415+
final ContiguousSet<Integer> checkedCreate(SortedSet<Integer> elementsSet) {
416416
List<Integer> elements = new ArrayList<>(elementsSet);
417417
/*
418418
* A ContiguousSet can't have holes. If a test demands a hole, it should be changed so that it

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.io.Serializable;
3030
import java.lang.reflect.Method;
3131
import java.lang.reflect.Proxy;
32+
import java.util.Iterator;
3233
import java.util.LinkedHashSet;
3334
import java.util.Set;
3435
import org.jspecify.annotations.NullMarked;
@@ -50,7 +51,22 @@ abstract class DummyProxy {
5051
*/
5152
final <T> T newProxy(TypeToken<T> interfaceType) {
5253
Set<Class<?>> interfaceClasses = new LinkedHashSet<>();
53-
interfaceClasses.addAll(interfaceType.getTypes().interfaces().rawTypes());
54+
Set<Class<? super T>> allInterfaceClasses = interfaceType.getTypes().interfaces().rawTypes();
55+
for (Class<? super T> itf : allInterfaceClasses) {
56+
Iterator<Class<?>> iterator = interfaceClasses.iterator();
57+
boolean addToSet = true;
58+
while (iterator.hasNext()) {
59+
Class<?> current = iterator.next();
60+
if (current == itf || itf.isAssignableFrom(current)) {
61+
// Skip any super interface of the ones that are already included.
62+
addToSet = false;
63+
break;
64+
}
65+
}
66+
if (addToSet) {
67+
interfaceClasses.add(itf);
68+
}
69+
}
5470
// Make the proxy serializable to work with SerializableTester
5571
interfaceClasses.add(Serializable.class);
5672
Object dummy =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ public boolean isExpectedType(Throwable cause) {
631631
}
632632
};
633633

634-
public abstract boolean isExpectedType(Throwable cause);
634+
abstract boolean isExpectedType(Throwable cause);
635635
}
636636

637637
private static boolean annotatedTypeExists() {

android/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.common.util.concurrent.testing;
1818

19+
import static java.util.concurrent.Executors.newCachedThreadPool;
20+
import static java.util.concurrent.Executors.newSingleThreadExecutor;
1921
import static java.util.concurrent.TimeUnit.MILLISECONDS;
2022
import static java.util.concurrent.TimeUnit.SECONDS;
2123
import static org.junit.Assert.assertThrows;
@@ -26,7 +28,6 @@
2628
import java.util.concurrent.CountDownLatch;
2729
import java.util.concurrent.ExecutionException;
2830
import java.util.concurrent.ExecutorService;
29-
import java.util.concurrent.Executors;
3031
import java.util.concurrent.Future;
3132
import java.util.concurrent.TimeUnit;
3233
import java.util.concurrent.TimeoutException;
@@ -71,7 +72,7 @@ public void testGetBlocksUntilValueAvailable() throws Throwable {
7172
assertFalse(future.isDone());
7273
assertFalse(future.isCancelled());
7374

74-
ExecutorService executor = Executors.newSingleThreadExecutor();
75+
ExecutorService executor = newSingleThreadExecutor();
7576

7677
try {
7778
Future<Boolean> getResult = executor.submit(() -> future.get());
@@ -138,7 +139,7 @@ public void testListenersNotifiedOnError() throws Exception {
138139
CountDownLatch successLatch = new CountDownLatch(1);
139140
CountDownLatch listenerLatch = new CountDownLatch(1);
140141

141-
ExecutorService exec = Executors.newCachedThreadPool();
142+
ExecutorService exec = newCachedThreadPool();
142143

143144
future.addListener(listenerLatch::countDown, exec);
144145

@@ -171,7 +172,7 @@ public void testListenersNotifiedOnError() throws Exception {
171172
public void testAllListenersCompleteSuccessfully()
172173
throws InterruptedException, ExecutionException {
173174

174-
ExecutorService exec = Executors.newCachedThreadPool();
175+
ExecutorService exec = newCachedThreadPool();
175176

176177
int listenerCount = 20;
177178
CountDownLatch listenerLatch = new CountDownLatch(listenerCount);

android/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.util.concurrent.testing;
1818

1919
import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService;
20+
import static java.util.concurrent.Executors.callable;
2021

2122
import com.google.common.annotations.GwtIncompatible;
2223
import com.google.common.base.Preconditions;
@@ -31,7 +32,6 @@
3132
import java.util.concurrent.Callable;
3233
import java.util.concurrent.Delayed;
3334
import java.util.concurrent.ExecutionException;
34-
import java.util.concurrent.Executors;
3535
import java.util.concurrent.Future;
3636
import java.util.concurrent.TimeUnit;
3737
import java.util.concurrent.TimeoutException;
@@ -136,7 +136,7 @@ public void execute(Runnable command) {
136136
public ListenableScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
137137
Preconditions.checkNotNull(command, "command must not be null");
138138
Preconditions.checkNotNull(unit, "unit must not be null!");
139-
return schedule(Executors.callable(command), delay, unit);
139+
return schedule(callable(command), delay, unit);
140140
}
141141

142142
@Override

android/guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.google.common.collect.ImmutableSet;
3737
import com.google.common.collect.testing.features.FeatureUtilTest.ExampleFeature.NotTesterAnnotation;
3838
import com.google.common.collect.testing.features.FeatureUtilTest.ExampleFeature.Require;
39+
import com.google.errorprone.annotations.Keep;
3940
import java.lang.annotation.Inherited;
4041
import java.lang.annotation.Retention;
4142
import java.lang.reflect.Method;
@@ -175,6 +176,7 @@ class Tester {}
175176
public void testBuildTesterRequirements_class_present_method_present() throws Exception {
176177
@Require(IMPLIES_BAR)
177178
class Tester {
179+
@Keep
178180
@Require(IMPLIES_IMPLIES_FOO)
179181
public void test() {}
180182
}
@@ -189,6 +191,7 @@ public void test() {}
189191
public void testBuildTesterRequirements_class_absent_method_absent() throws Exception {
190192
@Require(absent = IMPLIES_BAR)
191193
class Tester {
194+
@Keep
192195
@Require(absent = IMPLIES_IMPLIES_FOO)
193196
public void test() {}
194197
}
@@ -202,6 +205,7 @@ public void test() {}
202205
public void testBuildTesterRequirements_class_present_method_absent() throws Exception {
203206
@Require(IMPLIES_IMPLIES_FOO)
204207
class Tester {
208+
@Keep
205209
@Require(absent = IMPLIES_IMPLIES_FOO_AND_IMPLIES_BAR)
206210
public void test() {}
207211
}
@@ -217,6 +221,7 @@ public void test() {}
217221
public void testBuildTesterRequirements_class_absent_method_present() throws Exception {
218222
@Require(absent = IMPLIES_IMPLIES_FOO_AND_IMPLIES_BAR)
219223
class Tester {
224+
@Keep
220225
@Require(IMPLIES_IMPLIES_FOO)
221226
public void test() {}
222227
}
@@ -267,6 +272,7 @@ class Tester {}
267272
public void testBuildTesterRequirements_methodClassConflict() throws Exception {
268273
@Require(IMPLIES_FOO)
269274
class Tester {
275+
@Keep
270276
@Require(absent = FOO)
271277
public void test() {}
272278
}
@@ -301,6 +307,7 @@ class Tester {}
301307

302308
public void testGetTesterAnnotations_method() throws Exception {
303309
class Tester {
310+
@Keep
304311
@Require
305312
@NotTesterAnnotation
306313
public void test() {}

android/guava-testlib/test/com/google/common/testing/FakeTickerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.testing;
1818

1919
import static com.google.common.testing.ReflectionFreeAssertThrows.assertThrows;
20+
import static java.util.concurrent.Executors.newFixedThreadPool;
2021
import static java.util.concurrent.TimeUnit.MILLISECONDS;
2122
import static java.util.concurrent.TimeUnit.NANOSECONDS;
2223
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -27,7 +28,6 @@
2728
import java.util.concurrent.Callable;
2829
import java.util.concurrent.CountDownLatch;
2930
import java.util.concurrent.ExecutorService;
30-
import java.util.concurrent.Executors;
3131
import java.util.concurrent.Future;
3232
import java.util.concurrent.TimeUnit;
3333
import junit.framework.TestCase;
@@ -166,7 +166,7 @@ public void testConcurrentAutoIncrementStep() throws Exception {
166166
@GwtIncompatible // concurrency
167167
private void runConcurrentTest(int numberOfThreads, Callable<@Nullable Void> callable)
168168
throws Exception {
169-
ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads);
169+
ExecutorService executorService = newFixedThreadPool(numberOfThreads);
170170
CountDownLatch startLatch = new CountDownLatch(numberOfThreads);
171171
CountDownLatch doneLatch = new CountDownLatch(numberOfThreads);
172172
for (int i = numberOfThreads; i > 0; i--) {

android/guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ private interface Adder {
320320
private static class ForwardingArithmetic implements Arithmetic {
321321
private final Arithmetic arithmetic;
322322

323-
public ForwardingArithmetic(Arithmetic arithmetic) {
323+
ForwardingArithmetic(Arithmetic arithmetic) {
324324
this.arithmetic = arithmetic;
325325
}
326326

@@ -455,7 +455,7 @@ void foo(
455455
private static class ParameterTypesDifferentForwarder implements ParameterTypesDifferent {
456456
private final ParameterTypesDifferent delegate;
457457

458-
public ParameterTypesDifferentForwarder(ParameterTypesDifferent delegate) {
458+
ParameterTypesDifferentForwarder(ParameterTypesDifferent delegate) {
459459
this.delegate = delegate;
460460
}
461461

0 commit comments

Comments
 (0)