Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ see [`GsonBuilder.disableJdkUnsafe()`](https://javadoc.io/doc/com.google.code.gs

#### Minimum Android API level

- Gson 2.15.0 and newer: API level 24

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had been planning on releasing 2.14.1 next, but I think you're right that the change in Android SDK level implies upping the minor level.

- Gson 2.11.0 and newer: API level 21
- Gson 2.10.1 and older: API level 19

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.RandomAccess;
import java.util.Spliterator;

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

@Override
public void sort(Comparator<? super E> c) {
delegate.sort(c);
}

@Override
public Spliterator<E> spliterator() {
return delegate.spliterator();
}
Comment on lines +122 to +130

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are already covered by the tests in JsonArrayAsListTest.


@Override
public boolean equals(Object o) {
return delegate.equals(o);
Expand All @@ -126,7 +138,4 @@ public boolean equals(Object o) {
public int hashCode() {
return delegate.hashCode();
}

// Maybe also delegate List#sort and List#spliterator in the future, but that
// requires Android API level 24
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.google.gson.internal.bind;

import static java.lang.Math.toIntExact;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonIOException;
Expand Down Expand Up @@ -903,15 +905,6 @@ long[] integerValues(Calendar calendar) {
}
};

// TODO: update this when we are on at least Android API Level 24.
private static int toIntExact(long x) {
int i = (int) x;
if (i != x) {
throw new IllegalArgumentException("Too big for an int: " + x);
}
return i;
}

public static final TypeAdapterFactory CALENDAR_FACTORY =
newFactoryForMultipleTypes(Calendar.class, GregorianCalendar.class, CALENDAR);

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@
<configuration>
<skip>${gson.isTestModule}</skip>
<signature>
<!-- Google's internal use currently requires API Level 23 without desugaring. -->
<!-- Don't use https://github.com/open-toast/gummy-bears; Google's internal use currently does not support desugaring. -->
<groupId>net.sf.androidscents.signature</groupId>
<artifactId>android-api-level-24</artifactId>
<version>7.0_r2</version>
Expand Down