Skip to content

Commit 7f2f4e7

Browse files
Merge branch 'main' into lptaft
2 parents 14ddb30 + 9d5d6a8 commit 7f2f4e7

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ see [`GsonBuilder.disableJdkUnsafe()`](https://javadoc.io/doc/com.google.code.gs
6969

7070
#### Minimum Android API level
7171

72+
- Gson 2.15.0 and newer: API level 24
7273
- Gson 2.11.0 and newer: API level 21
7374
- Gson 2.10.1 and older: API level 19
7475

gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import java.util.AbstractList;
2020
import java.util.ArrayList;
2121
import java.util.Collection;
22+
import java.util.Comparator;
2223
import java.util.List;
2324
import java.util.Objects;
2425
import java.util.RandomAccess;
26+
import java.util.Spliterator;
2527

2628
/**
2729
* {@link List} which wraps another {@code List} but prevents insertion of {@code null} elements.
@@ -117,6 +119,16 @@ public <T> T[] toArray(T[] a) {
117119
return delegate.toArray(a);
118120
}
119121

122+
@Override
123+
public void sort(Comparator<? super E> c) {
124+
delegate.sort(c);
125+
}
126+
127+
@Override
128+
public Spliterator<E> spliterator() {
129+
return delegate.spliterator();
130+
}
131+
120132
@Override
121133
public boolean equals(Object o) {
122134
return delegate.equals(o);
@@ -126,7 +138,4 @@ public boolean equals(Object o) {
126138
public int hashCode() {
127139
return delegate.hashCode();
128140
}
129-
130-
// Maybe also delegate List#sort and List#spliterator in the future, but that
131-
// requires Android API level 24
132141
}

gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java

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

1717
package com.google.gson.internal.bind;
1818

19+
import static java.lang.Math.toIntExact;
20+
1921
import com.google.gson.Gson;
2022
import com.google.gson.JsonElement;
2123
import com.google.gson.JsonIOException;
@@ -903,15 +905,6 @@ long[] integerValues(Calendar calendar) {
903905
}
904906
};
905907

906-
// TODO: update this when we are on at least Android API Level 24.
907-
private static int toIntExact(long x) {
908-
int i = (int) x;
909-
if (i != x) {
910-
throw new IllegalArgumentException("Too big for an int: " + x);
911-
}
912-
return i;
913-
}
914-
915908
public static final TypeAdapterFactory CALENDAR_FACTORY =
916909
newFactoryForMultipleTypes(Calendar.class, GregorianCalendar.class, CALENDAR);
917910

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@
523523
<configuration>
524524
<skip>${gson.isTestModule}</skip>
525525
<signature>
526-
<!-- Google's internal use currently requires API Level 23 without desugaring. -->
526+
<!-- Don't use https://github.com/open-toast/gummy-bears; Google's internal use currently does not support desugaring. -->
527527
<groupId>net.sf.androidscents.signature</groupId>
528528
<artifactId>android-api-level-24</artifactId>
529529
<version>7.0_r2</version>

0 commit comments

Comments
 (0)