Skip to content

Commit

Permalink
Update version check
Browse files Browse the repository at this point in the history
this fix was backported to JDK 11u, which makes this work-around
kind of dicey.

PiperOrigin-RevId: 345152833
  • Loading branch information
cushon authored and Error Prone Team committed Dec 2, 2020
1 parent 4f635d4 commit 733d021
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions core/src/main/java/com/google/errorprone/refaster/Inliner.java
Expand Up @@ -23,7 +23,6 @@
import com.google.errorprone.SubContext;
import com.google.errorprone.refaster.UTypeVar.TypeWithExpression;
import com.google.errorprone.util.ASTHelpers;
import com.google.errorprone.util.RuntimeVersion;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Symbol.TypeSymbol;
Expand Down Expand Up @@ -234,13 +233,15 @@ public TypeVar inlineAsVar(UTypeVar var) throws CouldNotResolveImportException {
}

private static void setUpperBound(TypeVar typeVar, Type bound) {
// https://bugs.openjdk.java.net/browse/JDK-8193367
try {
// https://bugs.openjdk.java.net/browse/JDK-8193367
if (RuntimeVersion.isAtLeast13()) {
TypeVar.class.getMethod("setUpperBound", Type.class).invoke(typeVar, bound);
} else {
TypeVar.class.getField("bound").set(typeVar, bound);
}
TypeVar.class.getMethod("setUpperBound", Type.class).invoke(typeVar, bound);
return;
} catch (ReflectiveOperationException e) {
// continue below
}
try {
TypeVar.class.getField("bound").set(typeVar, bound);
} catch (ReflectiveOperationException e) {
throw new LinkageError(e.getMessage(), e);
}
Expand Down

0 comments on commit 733d021

Please sign in to comment.