Skip to content

Commit

Permalink
Internal build change
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 536961041
  • Loading branch information
stefanhaustein authored and Google Java Core Libraries committed Jun 1, 2023
1 parent 1c4e253 commit b6193d1
Show file tree
Hide file tree
Showing 50 changed files with 386 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -360,10 +362,48 @@ public static <T> Collection<T> misleadingSizeCollection(int delta) {
// It would be nice to be able to return a real concurrent
// collection like ConcurrentLinkedQueue, so that e.g. concurrent
// iteration would work, but that would not be GWT-compatible.
return new ArrayList<T>() {
// We are not "just" inheriting from ArrayList here as this doesn't work for J2kt.
return new AbstractList<T>() {
ArrayList<T> data = new ArrayList<>();

@Override
public int size() {
return Math.max(0, super.size() + delta);
return Math.max(0, data.size() + delta);
}

@Override
public T get(int index) {
return data.get(index);
}

@Override
public T set(int index, T element) {
return data.set(index, element);
}

@Override
public boolean add(T element) {
return data.add(element);
}

@Override
public void add(int index, T element) {
data.add(index, element);
}

@Override
public T remove(int index) {
return data.remove(index);
}

@Override
public <T> T[] toArray(T[] a) {
return data.toArray(a);
}

@Override
public Object[] toArray() {
return data.toArray();
}
};
}
Expand Down Expand Up @@ -525,6 +565,7 @@ private NullsBeforeTwo() {
}
}

@J2ktIncompatible
@GwtIncompatible // reflection
public static Method getMethod(Class<?> clazz, String name) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.collect.testing.Helpers;
import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
Expand Down Expand Up @@ -172,6 +173,7 @@ public void testLexicographicalComparator() {
Helpers.testComparator(comparator, ordered);
}

@J2ktIncompatible
@GwtIncompatible // SerializableTester
public void testLexicographicalComparatorSerializable() {
Comparator<boolean[]> comparator = Booleans.lexicographicalComparator();
Expand Down Expand Up @@ -592,6 +594,7 @@ public void testCountTrue() {
assertThat(Booleans.countTrue(false, false, true, false, false)).isEqualTo(1);
}

@J2ktIncompatible
@GwtIncompatible // NullPointerTester
public void testNulls() {
new NullPointerTester().testAllPublicStaticMethods(Booleans.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.testing.ListTestSuiteBuilder;
import com.google.common.collect.testing.SampleElements;
Expand Down Expand Up @@ -48,6 +49,7 @@ private static List<Byte> asList(Byte[] values) {
return Bytes.asList(temp);
}

@J2ktIncompatible
@GwtIncompatible // suite
public static Test suite() {
List<ListTestSuiteBuilder<Byte>> builders =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.collect.testing.Helpers;
import com.google.common.testing.NullPointerTester;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import junit.framework.TestCase;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* Unit test for {@link Bytes}.
*
* @author Kevin Bourrillion
*/
@ElementTypesAreNonnullByDefault
@GwtCompatible(emulated = true)
public class BytesTest extends TestCase {
private static final byte[] EMPTY = {};
Expand Down Expand Up @@ -182,7 +185,7 @@ public void testToArray_threadSafe() {
}

public void testToArray_withNull() {
List<Byte> list = Arrays.asList((byte) 0, (byte) 1, null);
List<@Nullable Byte> list = Arrays.asList((byte) 0, (byte) 1, null);
try {
Bytes.toArray(list);
fail();
Expand All @@ -208,6 +211,7 @@ public void testToArray_withConversion() {
assertThat(Bytes.toArray(doubles)).isEqualTo(array);
}

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

@J2ktIncompatible
@GwtIncompatible // NullPointerTester
public void testNulls() {
new NullPointerTester().testAllPublicStaticMethods(Bytes.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.testing.ListTestSuiteBuilder;
import com.google.common.collect.testing.SampleElements;
Expand Down Expand Up @@ -48,6 +49,7 @@ private static List<Character> asList(Character[] values) {
return Chars.asList(temp);
}

@J2ktIncompatible
@GwtIncompatible // suite
public static Test suite() {
List<ListTestSuiteBuilder<Character>> builders =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.collect.testing.Helpers;
import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
Expand Down Expand Up @@ -221,12 +222,14 @@ public void testConcat() {
.isEqualTo(new char[] {(char) 1, (char) 2, (char) 3, (char) 4});
}

@J2ktIncompatible
@GwtIncompatible // Chars.fromByteArray
public void testFromByteArray() {
assertThat(Chars.fromByteArray(new byte[] {0x23, 0x45, (byte) 0xDC})).isEqualTo('\u2345');
assertThat(Chars.fromByteArray(new byte[] {(byte) 0xFE, (byte) 0xDC})).isEqualTo('\uFEDC');
}

@J2ktIncompatible
@GwtIncompatible // Chars.fromByteArray
public void testFromByteArrayFails() {
try {
Expand All @@ -236,12 +239,14 @@ public void testFromByteArrayFails() {
}
}

@J2ktIncompatible
@GwtIncompatible // Chars.fromBytes
public void testFromBytes() {
assertThat(Chars.fromBytes((byte) 0x23, (byte) 0x45)).isEqualTo('\u2345');
assertThat(Chars.fromBytes((byte) 0xFE, (byte) 0xDC)).isEqualTo('\uFEDC');
}

@J2ktIncompatible
@GwtIncompatible // Chars.fromByteArray, Chars.toByteArray
public void testByteArrayRoundTrips() {
char c = 0;
Expand Down Expand Up @@ -269,6 +274,7 @@ public void testByteArrayRoundTrips() {
assertThat(c).isEqualTo((char) 0); // sanity check
}

@J2ktIncompatible
@GwtIncompatible // Chars.fromByteArray, Chars.toByteArray
public void testByteArrayRoundTripsFails() {
try {
Expand Down Expand Up @@ -324,6 +330,7 @@ public void testLexicographicalComparator() {
Helpers.testComparator(comparator, ordered);
}

@J2ktIncompatible
@GwtIncompatible // SerializableTester
public void testLexicographicalComparatorSerializable() {
Comparator<char[]> comparator = Chars.lexicographicalComparator();
Expand Down Expand Up @@ -659,6 +666,7 @@ public void testAsListEmpty() {
assertThat(Chars.asList(EMPTY)).isSameInstanceAs(Collections.emptyList());
}

@J2ktIncompatible
@GwtIncompatible // NullPointerTester
public void testNulls() {
new NullPointerTester().testAllPublicStaticMethods(Chars.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.testing.ListTestSuiteBuilder;
import com.google.common.collect.testing.SampleElements;
Expand Down Expand Up @@ -48,6 +49,7 @@ private static List<Double> asList(Double[] values) {
return Doubles.asList(temp);
}

@J2ktIncompatible
@GwtIncompatible // suite
public static Test suite() {
List<ListTestSuiteBuilder<Double>> builders =
Expand Down
Loading

0 comments on commit b6193d1

Please sign in to comment.