aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2014-08-21 22:23:17 +0200
committerRoel Spilker <r.spilker@gmail.com>2014-08-21 22:23:17 +0200
commiteba2a515fa3f4c773f3b38ef3510c70f941210cc (patch)
treef746ae2e496a1a27b7499ebb765f04b11c8c428c /src
parent836c6e865e1a41ee98e271b6ed24a62a16a4f682 (diff)
downloadlombok-eba2a515fa3f4c773f3b38ef3510c70f941210cc.tar.gz
lombok-eba2a515fa3f4c773f3b38ef3510c70f941210cc.tar.bz2
lombok-eba2a515fa3f4c773f3b38ef3510c70f941210cc.zip
[i731] javac resolution broken by 1.8.0_20; fixed with some reflection voodoo. -R&R
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/javac/JavacResolution.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index ec455b18..23d7d482 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -24,11 +24,15 @@ package lombok.javac;
import static lombok.javac.Javac.*;
import static lombok.javac.JavacTreeMaker.TypeTag.typeTag;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayDeque;
import java.util.Map;
import javax.lang.model.type.TypeKind;
+import lombok.Lombok;
+
import com.sun.tools.javac.code.BoundKind;
import com.sun.tools.javac.code.Symbol.TypeSymbol;
import com.sun.tools.javac.code.Symtab;
@@ -179,10 +183,37 @@ public class JavacResolution {
}
}
+ private static class ReflectiveAccess {
+ private static Method UPPER_BOUND;
+
+ static {
+ Method upperBound = null;
+ try {
+ upperBound = Types.class.getMethod("upperBound", Type.class);
+ } catch (Throwable ignore) {}
+ if (upperBound == null) try {
+ upperBound = Types.class.getMethod("wildUpperBound", Type.class);
+ } catch (Throwable ignore) {}
+
+ UPPER_BOUND = upperBound;
+ }
+
+ public static Type Types_upperBound(Types types, Type type) {
+ try {
+ return (Type) UPPER_BOUND.invoke(types, type);
+ } catch (InvocationTargetException e) {
+ throw Lombok.sneakyThrow(e.getCause());
+ } catch (Exception e) {
+ throw Lombok.sneakyThrow(e);
+ }
+ }
+ }
+
public static Type ifTypeIsIterableToComponent(Type type, JavacAST ast) {
Types types = Types.instance(ast.getContext());
Symtab syms = Symtab.instance(ast.getContext());
- Type boundType = types.upperBound(type);
+ Type boundType = ReflectiveAccess.Types_upperBound(types, type);
+// Type boundType = types.upperBound(type);
Type elemTypeIfArray = types.elemtype(boundType);
if (elemTypeIfArray != null) return elemTypeIfArray;
@@ -190,7 +221,7 @@ public class JavacResolution {
if (base == null) return syms.objectType;
List<Type> iterableParams = base.allparams();
- return iterableParams.isEmpty() ? syms.objectType : types.upperBound(iterableParams.head);
+ return iterableParams.isEmpty() ? syms.objectType : ReflectiveAccess.Types_upperBound(types, iterableParams.head);
}
public static JCExpression typeToJCTree(Type type, JavacAST ast, boolean allowVoid) throws TypeNotConvertibleException {