Don't rely on javac's (broken) handling of wildcard erasure. The JLS doesn't define what erasing a wildcard means, but a javac bug caused it to try to erase wildcards anyways. The bug will be fixed in an upcoming version of javac [1], which breaks this code. This change implements wildcard simplification to match the class javadoc: ? extends Foo -> erasure(Foo) and: ? -> Object [1] https://bugs.openjdk.java.net/browse/JDK-8055054 Change-Id: I0dbce8849a03c48bc838b8ad47a6ccd535257148 Review-Link: https://gwt-review.googlesource.com/#/c/9681/ (cherry picked from commit a5df12388dcfb79ecb333ddb8e5279931e2246c3)
diff --git a/user/src/com/google/web/bindery/requestfactory/apt/TypeSimplifier.java b/user/src/com/google/web/bindery/requestfactory/apt/TypeSimplifier.java index 676005f..83730bd 100644 --- a/user/src/com/google/web/bindery/requestfactory/apt/TypeSimplifier.java +++ b/user/src/com/google/web/bindery/requestfactory/apt/TypeSimplifier.java
@@ -102,7 +102,15 @@ @Override public TypeMirror visitWildcard(WildcardType x, State state) { - return state.types.erasure(x).accept(this, state); + // The JLS doesn't define erasure for wildcards [1], so don't rely on + // javac's implementation. Instead, simplify wildcards as: + // ? extends Foo -> erasure(Foo) + // and: ? -> Object + // + // [1] https://bugs.openjdk.java.net/browse/JDK-8055054 + return x.getExtendsBound() != null + ? x.getExtendsBound().accept(this, state) + : state.findType(Object.class); } @Override