aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--doc/changelog.markdown4
-rw-r--r--src/core/lombok/javac/JavacResolution.java35
2 files changed, 35 insertions, 4 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 40a8e312..c7d4ad90 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -2,7 +2,7 @@ Lombok Changelog
----------------
### v1.14.5 "Edgy Guinea Pig"
-
+* BUGFIX: Usage of `val` would break starting with JDK8 release `1.8.0_20`. [Issue #731](https://code.google.com/p/projectlombok/issues/detail?id=731)
* WORK-IN-PROGRESS: A bunch of errors in the error log about 'Path must include project and resource name' seem to be related to slowdowns. This fix removes the errors, but does it remove the slowdowns? [Issue #682](https://code.google.com/p/projectlombok/issues/detail?id=682).
This edge release contains some special flags:
@@ -12,7 +12,7 @@ Lombok Changelog
2. `-Dlombok.disableConfig`: Disables the config system (notably including all attempts to look up the location of, and read, `lombok.config` files) entirely.
Both flags can be used simultaneously. Add either or both of these switches in your `eclipse.ini`, directly under `-javaagent:lombok.jar`.
-
+
### v1.14.4 (July 1st, 2014)
* BUGFIX: GWT produces errors in handlers on line 1 in any source files that use lombok; this has been fixed. [Issue #699](https://code.google.com/p/projectlombok/issues/detail?id=699)
* BUGFIX-IN-PROGRESS: Many pathfinder issues in eclipse (see the bugfix in progress in v1.14.2) have now been fixed. [Issue #682](https://code.google.com/p/projectlombok/issues/detail?id=682)
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 {