Work around a change in the JDK 11 JCFunctionalExpression
The AST node now stores a single target type instead of a list.
Change on 2018/09/28 by cushon
@@ -779,17 +779,35 @@ public class TreeConverter {
return newNode;
}
- private TreeNode convertFunctionalExpression(JCTree.JCFunctionalExpression node,
- FunctionalExpression newNode) {
- for (TypeMirror type : node.targets) {
+ private TreeNode convertFunctionalExpression(
+ JCTree.JCFunctionalExpression node, FunctionalExpression newNode) {
+ for (TypeMirror type : getTargets(node)) {
newNode.addTargetType(type);
}
- return newNode.setTypeMirror(node.type)
- .setDescriptor(new ExecutablePair(
- (ExecutableElement) types.findDescriptorSymbol(node.targets.head.tsym),
+ return newNode
+ .setTypeMirror(getTargets(node).iterator().next())
+ .setDescriptor(
+ new ExecutablePair(
+ (ExecutableElement) types.findDescriptorSymbol(getTargets(node).head.tsym),
(ExecutableType) node.getDescriptorType(types)));
}
+ private static com.sun.tools.javac.util.List<com.sun.tools.javac.code.Type> getTargets(
+ JCTree.JCFunctionalExpression node) {
+ try {
+ return node.targets;
+ } catch (NoSuchFieldError e) {
+ // continue below
+ }
+ try {
+ return com.sun.tools.javac.util.List.of(
+ (com.sun.tools.javac.code.Type)
+ JCTree.JCFunctionalExpression.class.getField("target").get(node));
+ } catch (ReflectiveOperationException e) {
+ throw new LinkageError(e.getMessage(), e);
+ }
+ }
+
private TreeNode convertIdent(JCTree.JCIdent node) {
String text = node.sym.toString();
if (text.equals("this")) {
