Skip to content

Commit b6193d1

Browse files
stefanhausteinGoogle Java Core Libraries
authored and
Google Java Core Libraries
committed
Internal build change
RELNOTES=n/a PiperOrigin-RevId: 536961041
1 parent 1c4e253 commit b6193d1

Some content is hidden

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

50 files changed

+386
-6
lines changed

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

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323

2424
import com.google.common.annotations.GwtCompatible;
2525
import com.google.common.annotations.GwtIncompatible;
26+
import com.google.common.annotations.J2ktIncompatible;
2627
import com.google.errorprone.annotations.CanIgnoreReturnValue;
2728
import java.io.Serializable;
2829
import java.lang.reflect.Method;
30+
import java.util.AbstractList;
2931
import java.util.ArrayList;
3032
import java.util.Arrays;
3133
import java.util.Collection;
@@ -360,10 +362,48 @@ public static <T> Collection<T> misleadingSizeCollection(int delta) {
360362
// It would be nice to be able to return a real concurrent
361363
// collection like ConcurrentLinkedQueue, so that e.g. concurrent
362364
// iteration would work, but that would not be GWT-compatible.
363-
return new ArrayList<T>() {
365+
// We are not "just" inheriting from ArrayList here as this doesn't work for J2kt.
366+
return new AbstractList<T>() {
367+
ArrayList<T> data = new ArrayList<>();
368+
364369
@Override
365370
public int size() {
366-
return Math.max(0, super.size() + delta);
371+
return Math.max(0, data.size() + delta);
372+
}
373+
374+
@Override
375+
public T get(int index) {
376+
return data.get(index);
377+
}
378+
379+
@Override
380+
public T set(int index, T element) {
381+
return data.set(index, element);
382+
}
383+
384+
@Override
385+
public boolean add(T element) {
386+
return data.add(element);
387+
}
388+
389+
@Override
390+
public void add(int index, T element) {
391+
data.add(index, element);
392+
}
393+
394+
@Override
395+
public T remove(int index) {
396+
return data.remove(index);
397+
}
398+
399+
@Override
400+
public <T> T[] toArray(T[] a) {
401+
return data.toArray(a);
402+
}
403+
404+
@Override
405+
public Object[] toArray() {
406+
return data.toArray();
367407
}
368408
};
369409
}
@@ -525,6 +565,7 @@ private NullsBeforeTwo() {
525565
}
526566
}
527567

568+
@J2ktIncompatible
528569
@GwtIncompatible // reflection
529570
public static Method getMethod(Class<?> clazz, String name) {
530571
try {

android/guava-tests/test/com/google/common/primitives/BooleansTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.google.common.annotations.GwtCompatible;
2323
import com.google.common.annotations.GwtIncompatible;
24+
import com.google.common.annotations.J2ktIncompatible;
2425
import com.google.common.collect.testing.Helpers;
2526
import com.google.common.testing.NullPointerTester;
2627
import com.google.common.testing.SerializableTester;
@@ -172,6 +173,7 @@ public void testLexicographicalComparator() {
172173
Helpers.testComparator(comparator, ordered);
173174
}
174175

176+
@J2ktIncompatible
175177
@GwtIncompatible // SerializableTester
176178
public void testLexicographicalComparatorSerializable() {
177179
Comparator<boolean[]> comparator = Booleans.lexicographicalComparator();
@@ -592,6 +594,7 @@ public void testCountTrue() {
592594
assertThat(Booleans.countTrue(false, false, true, false, false)).isEqualTo(1);
593595
}
594596

597+
@J2ktIncompatible
595598
@GwtIncompatible // NullPointerTester
596599
public void testNulls() {
597600
new NullPointerTester().testAllPublicStaticMethods(Booleans.class);

android/guava-tests/test/com/google/common/primitives/ByteArrayAsListTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import com.google.common.annotations.GwtCompatible;
2222
import com.google.common.annotations.GwtIncompatible;
23+
import com.google.common.annotations.J2ktIncompatible;
2324
import com.google.common.collect.ImmutableList;
2425
import com.google.common.collect.testing.ListTestSuiteBuilder;
2526
import com.google.common.collect.testing.SampleElements;
@@ -48,6 +49,7 @@ private static List<Byte> asList(Byte[] values) {
4849
return Bytes.asList(temp);
4950
}
5051

52+
@J2ktIncompatible
5153
@GwtIncompatible // suite
5254
public static Test suite() {
5355
List<ListTestSuiteBuilder<Byte>> builders =

android/guava-tests/test/com/google/common/primitives/BytesTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,22 @@
2020

2121
import com.google.common.annotations.GwtCompatible;
2222
import com.google.common.annotations.GwtIncompatible;
23+
import com.google.common.annotations.J2ktIncompatible;
2324
import com.google.common.collect.testing.Helpers;
2425
import com.google.common.testing.NullPointerTester;
2526
import java.util.Arrays;
2627
import java.util.Collection;
2728
import java.util.Collections;
2829
import java.util.List;
2930
import junit.framework.TestCase;
31+
import org.checkerframework.checker.nullness.qual.Nullable;
3032

3133
/**
3234
* Unit test for {@link Bytes}.
3335
*
3436
* @author Kevin Bourrillion
3537
*/
38+
@ElementTypesAreNonnullByDefault
3639
@GwtCompatible(emulated = true)
3740
public class BytesTest extends TestCase {
3841
private static final byte[] EMPTY = {};
@@ -182,7 +185,7 @@ public void testToArray_threadSafe() {
182185
}
183186

184187
public void testToArray_withNull() {
185-
List<Byte> list = Arrays.asList((byte) 0, (byte) 1, null);
188+
List<@Nullable Byte> list = Arrays.asList((byte) 0, (byte) 1, null);
186189
try {
187190
Bytes.toArray(list);
188191
fail();
@@ -208,6 +211,7 @@ public void testToArray_withConversion() {
208211
assertThat(Bytes.toArray(doubles)).isEqualTo(array);
209212
}
210213

214+
@J2ktIncompatible // TODO(b/278877942): Enable
211215
public void testAsList_isAView() {
212216
byte[] array = {(byte) 0, (byte) 1};
213217
List<Byte> list = Bytes.asList(array);
@@ -367,6 +371,7 @@ public void testRotateIndexed() {
367371
testRotate(new byte[] {0, 1, 2, 3, 4, 5, 6}, 3, 3, 7, new byte[] {0, 1, 2, 4, 5, 6, 3});
368372
}
369373

374+
@J2ktIncompatible
370375
@GwtIncompatible // NullPointerTester
371376
public void testNulls() {
372377
new NullPointerTester().testAllPublicStaticMethods(Bytes.class);

android/guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import com.google.common.annotations.GwtCompatible;
2222
import com.google.common.annotations.GwtIncompatible;
23+
import com.google.common.annotations.J2ktIncompatible;
2324
import com.google.common.collect.ImmutableList;
2425
import com.google.common.collect.testing.ListTestSuiteBuilder;
2526
import com.google.common.collect.testing.SampleElements;
@@ -48,6 +49,7 @@ private static List<Character> asList(Character[] values) {
4849
return Chars.asList(temp);
4950
}
5051

52+
@J2ktIncompatible
5153
@GwtIncompatible // suite
5254
public static Test suite() {
5355
List<ListTestSuiteBuilder<Character>> builders =

android/guava-tests/test/com/google/common/primitives/CharsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.google.common.annotations.GwtCompatible;
2323
import com.google.common.annotations.GwtIncompatible;
24+
import com.google.common.annotations.J2ktIncompatible;
2425
import com.google.common.collect.testing.Helpers;
2526
import com.google.common.testing.NullPointerTester;
2627
import com.google.common.testing.SerializableTester;
@@ -221,12 +222,14 @@ public void testConcat() {
221222
.isEqualTo(new char[] {(char) 1, (char) 2, (char) 3, (char) 4});
222223
}
223224

225+
@J2ktIncompatible
224226
@GwtIncompatible // Chars.fromByteArray
225227
public void testFromByteArray() {
226228
assertThat(Chars.fromByteArray(new byte[] {0x23, 0x45, (byte) 0xDC})).isEqualTo('\u2345');
227229
assertThat(Chars.fromByteArray(new byte[] {(byte) 0xFE, (byte) 0xDC})).isEqualTo('\uFEDC');
228230
}
229231

232+
@J2ktIncompatible
230233
@GwtIncompatible // Chars.fromByteArray
231234
public void testFromByteArrayFails() {
232235
try {
@@ -236,12 +239,14 @@ public void testFromByteArrayFails() {
236239
}
237240
}
238241

242+
@J2ktIncompatible
239243
@GwtIncompatible // Chars.fromBytes
240244
public void testFromBytes() {
241245
assertThat(Chars.fromBytes((byte) 0x23, (byte) 0x45)).isEqualTo('\u2345');
242246
assertThat(Chars.fromBytes((byte) 0xFE, (byte) 0xDC)).isEqualTo('\uFEDC');
243247
}
244248

249+
@J2ktIncompatible
245250
@GwtIncompatible // Chars.fromByteArray, Chars.toByteArray
246251
public void testByteArrayRoundTrips() {
247252
char c = 0;
@@ -269,6 +274,7 @@ public void testByteArrayRoundTrips() {
269274
assertThat(c).isEqualTo((char) 0); // sanity check
270275
}
271276

277+
@J2ktIncompatible
272278
@GwtIncompatible // Chars.fromByteArray, Chars.toByteArray
273279
public void testByteArrayRoundTripsFails() {
274280
try {
@@ -324,6 +330,7 @@ public void testLexicographicalComparator() {
324330
Helpers.testComparator(comparator, ordered);
325331
}
326332

333+
@J2ktIncompatible
327334
@GwtIncompatible // SerializableTester
328335
public void testLexicographicalComparatorSerializable() {
329336
Comparator<char[]> comparator = Chars.lexicographicalComparator();
@@ -659,6 +666,7 @@ public void testAsListEmpty() {
659666
assertThat(Chars.asList(EMPTY)).isSameInstanceAs(Collections.emptyList());
660667
}
661668

669+
@J2ktIncompatible
662670
@GwtIncompatible // NullPointerTester
663671
public void testNulls() {
664672
new NullPointerTester().testAllPublicStaticMethods(Chars.class);

android/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import com.google.common.annotations.GwtCompatible;
2222
import com.google.common.annotations.GwtIncompatible;
23+
import com.google.common.annotations.J2ktIncompatible;
2324
import com.google.common.collect.ImmutableList;
2425
import com.google.common.collect.testing.ListTestSuiteBuilder;
2526
import com.google.common.collect.testing.SampleElements;
@@ -48,6 +49,7 @@ private static List<Double> asList(Double[] values) {
4849
return Doubles.asList(temp);
4950
}
5051

52+
@J2ktIncompatible
5153
@GwtIncompatible // suite
5254
public static Test suite() {
5355
List<ListTestSuiteBuilder<Double>> builders =

0 commit comments

Comments
 (0)