Skip to content

Commit

Permalink
Small fixes to progress towards building Guava on JDK 17.
Browse files Browse the repository at this point in the history
* JDK 15 introduced a default method `CharSequence.isEmpty()` and that makes a type variable `<T extends List<E> & CharSequence>` illegal. Use `Serializable` instead of `CharSequence` (we're only testing reflection on type variables, not actually using this).

* `FuturesGetCheckedBenchmark` has a list of example exception classes which included one from the now-deleted package `java.security.acl`. Use a different exception instead.

RELNOTES=n/a
PiperOrigin-RevId: 436368651
  • Loading branch information
eamonnmcmanus authored and Google Java Core Libraries committed Mar 22, 2022
1 parent df55981 commit 7e04a00
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.security.acl.NotOwnerException;
import java.security.KeyException;
import java.util.List;
import java.util.TooManyListenersException;
import java.util.concurrent.BrokenBarrierException;
Expand Down Expand Up @@ -91,7 +91,7 @@ private enum ExceptionType {
ExecutionException.class,
GeneralSecurityException.class,
InvalidPreferencesFormatException.class,
NotOwnerException.class,
KeyException.class,
RefreshFailedException.class,
TimeoutException.class,
TooManyListenersException.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,37 +402,37 @@ public <T> void testGetGenericSuperclass_typeVariable_unbounded() {
assertEquals(TypeToken.of(Object.class), new TypeToken<T[]>() {}.getGenericSuperclass());
}

public <T extends ArrayList<String> & CharSequence>
public <T extends ArrayList<String> & Serializable>
void testGetGenericSuperclass_typeVariable_boundIsClass() {
assertEquals(
new TypeToken<ArrayList<String>>() {},
TypeToken.of(new TypeCapture<T>() {}.capture()).getGenericSuperclass());
assertEquals(TypeToken.of(Object.class), new TypeToken<T[]>() {}.getGenericSuperclass());
}

public <T extends Enum<T> & CharSequence>
public <T extends Enum<T> & Serializable>
void testGetGenericSuperclass_typeVariable_boundIsFBoundedClass() {
assertEquals(
new TypeToken<Enum<T>>() {},
TypeToken.of(new TypeCapture<T>() {}.capture()).getGenericSuperclass());
assertEquals(TypeToken.of(Object.class), new TypeToken<T[]>() {}.getGenericSuperclass());
}

public <T extends List<String> & CharSequence>
public <T extends List<String> & Serializable>
void testGetGenericSuperclass_typeVariable_boundIsInterface() {
assertNull(TypeToken.of(new TypeCapture<T>() {}.capture()).getGenericSuperclass());
assertEquals(TypeToken.of(Object.class), new TypeToken<T[]>() {}.getGenericSuperclass());
}

public <T extends ArrayList<String> & CharSequence, T1 extends T>
public <T extends ArrayList<String> & Serializable, T1 extends T>
void testGetGenericSuperclass_typeVariable_boundIsTypeVariableAndClass() {
assertEquals(
TypeToken.of(new TypeCapture<T>() {}.capture()),
TypeToken.of(new TypeCapture<T1>() {}.capture()).getGenericSuperclass());
assertEquals(TypeToken.of(Object.class), new TypeToken<T[]>() {}.getGenericSuperclass());
}

public <T extends List<String> & CharSequence, T1 extends T>
public <T extends List<String> & Serializable, T1 extends T>
void testGetGenericSuperclass_typeVariable_boundIsTypeVariableAndInterface() {
assertNull(TypeToken.of(new TypeCapture<T1>() {}.capture()).getGenericSuperclass());
assertEquals(TypeToken.of(Object.class), new TypeToken<T1[]>() {}.getGenericSuperclass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.security.acl.NotOwnerException;
import java.security.KeyException;
import java.util.List;
import java.util.TooManyListenersException;
import java.util.concurrent.BrokenBarrierException;
Expand Down Expand Up @@ -93,7 +93,7 @@ private enum ExceptionType {
ExecutionException.class,
GeneralSecurityException.class,
InvalidPreferencesFormatException.class,
NotOwnerException.class,
KeyException.class,
RefreshFailedException.class,
TimeoutException.class,
TooManyListenersException.class,
Expand Down
10 changes: 5 additions & 5 deletions guava-tests/test/com/google/common/reflect/TypeTokenTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -402,37 +402,37 @@ public <T> void testGetGenericSuperclass_typeVariable_unbounded() {
assertEquals(TypeToken.of(Object.class), new TypeToken<T[]>() {}.getGenericSuperclass());
}

public <T extends ArrayList<String> & CharSequence>
public <T extends ArrayList<String> & Serializable>
void testGetGenericSuperclass_typeVariable_boundIsClass() {
assertEquals(
new TypeToken<ArrayList<String>>() {},
TypeToken.of(new TypeCapture<T>() {}.capture()).getGenericSuperclass());
assertEquals(TypeToken.of(Object.class), new TypeToken<T[]>() {}.getGenericSuperclass());
}

public <T extends Enum<T> & CharSequence>
public <T extends Enum<T> & Serializable>
void testGetGenericSuperclass_typeVariable_boundIsFBoundedClass() {
assertEquals(
new TypeToken<Enum<T>>() {},
TypeToken.of(new TypeCapture<T>() {}.capture()).getGenericSuperclass());
assertEquals(TypeToken.of(Object.class), new TypeToken<T[]>() {}.getGenericSuperclass());
}

public <T extends List<String> & CharSequence>
public <T extends List<String> & Serializable>
void testGetGenericSuperclass_typeVariable_boundIsInterface() {
assertNull(TypeToken.of(new TypeCapture<T>() {}.capture()).getGenericSuperclass());
assertEquals(TypeToken.of(Object.class), new TypeToken<T[]>() {}.getGenericSuperclass());
}

public <T extends ArrayList<String> & CharSequence, T1 extends T>
public <T extends ArrayList<String> & Serializable, T1 extends T>
void testGetGenericSuperclass_typeVariable_boundIsTypeVariableAndClass() {
assertEquals(
TypeToken.of(new TypeCapture<T>() {}.capture()),
TypeToken.of(new TypeCapture<T1>() {}.capture()).getGenericSuperclass());
assertEquals(TypeToken.of(Object.class), new TypeToken<T[]>() {}.getGenericSuperclass());
}

public <T extends List<String> & CharSequence, T1 extends T>
public <T extends List<String> & Serializable, T1 extends T>
void testGetGenericSuperclass_typeVariable_boundIsTypeVariableAndInterface() {
assertNull(TypeToken.of(new TypeCapture<T1>() {}.capture()).getGenericSuperclass());
assertEquals(TypeToken.of(Object.class), new TypeToken<T1[]>() {}.getGenericSuperclass());
Expand Down

0 comments on commit 7e04a00

Please sign in to comment.