com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind Java Examples

The following examples show how to use com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LambdaToMethod.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
ReferenceTranslationContext(JCMemberReference tree) {
    super(tree);
    this.isSuper = tree.hasKind(ReferenceKind.SUPER);
    this.bridgeSym = needsBridge()
            ? makePrivateSyntheticMethod(isSuper ? 0 : STATIC,
                                  referenceBridgeName(), null,
                                  owner.enclClass())
            : null;
    this.sigPolySym = isSignaturePolymorphic()
            ? makePrivateSyntheticMethod(tree.sym.flags(),
                                  tree.sym.name,
                                  bridgedRefSig(),
                                  tree.sym.enclClass())
            : null;
    if (dumpLambdaToMethodStats) {
        String key = bridgeSym == null ?
                "mref.stat" : "mref.stat.1";
        log.note(tree, key, needsAltMetafactory(), bridgeSym);
    }
}
 
Example #2
Source File: LambdaToMethod.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Lambda body to use for a 'new'.
 */
private JCExpression expressionNew() {
    if (tree.kind == ReferenceKind.ARRAY_CTOR) {
        //create the array creation expression
        JCNewArray newArr = make.NewArray(
                make.Type(types.elemtype(tree.getQualifierExpression().type)),
                List.of(make.Ident(params.first())),
                null);
        newArr.type = tree.getQualifierExpression().type;
        return newArr;
    } else {
        //create the instance creation expression
        //note that method reference syntax does not allow an explicit
        //enclosing class (so the enclosing class is null)
        JCNewClass newClass = make.NewClass(null,
                List.<JCExpression>nil(),
                make.Type(tree.getQualifierExpression().type),
                convertArgs(tree.sym, args.toList(), tree.varargsElement),
                null);
        newClass.constructor = tree.sym;
        newClass.constructorType = tree.sym.erasure(types);
        newClass.type = tree.getQualifierExpression().type;
        setVarargsIfNeeded(newClass, tree.varargsElement);
        return newClass;
    }
}
 
Example #3
Source File: LambdaToMethod.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Erasure destroys the implementation parameter subtype
 * relationship for intersection types
 */
boolean interfaceParameterIsIntersectionType() {
    List<Type> tl = tree.getDescriptorType(types).getParameterTypes();
    if (tree.kind == ReferenceKind.UNBOUND) {
        tl = tl.tail;
    }
    for (; tl.nonEmpty(); tl = tl.tail) {
        Type pt = tl.head;
        if (pt.getKind() == TypeKind.TYPEVAR) {
            TypeVar tv = (TypeVar) pt;
            if (tv.bound.getKind() == TypeKind.INTERSECTION) {
                return true;
            }
        }
    }
    return false;
}
 
Example #4
Source File: LambdaToMethod.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Lambda body to use for a 'new'.
 */
private JCExpression expressionNew() {
    if (tree.kind == ReferenceKind.ARRAY_CTOR) {
        //create the array creation expression
        JCNewArray newArr = make.NewArray(
                make.Type(types.elemtype(tree.getQualifierExpression().type)),
                List.of(make.Ident(params.first())),
                null);
        newArr.type = tree.getQualifierExpression().type;
        return newArr;
    } else {
        //create the instance creation expression
        //note that method reference syntax does not allow an explicit
        //enclosing class (so the enclosing class is null)
        JCNewClass newClass = make.NewClass(null,
                List.<JCExpression>nil(),
                make.Type(tree.getQualifierExpression().type),
                convertArgs(tree.sym, args.toList(), tree.varargsElement),
                null);
        newClass.constructor = tree.sym;
        newClass.constructorType = tree.sym.erasure(types);
        newClass.type = tree.getQualifierExpression().type;
        setVarargsIfNeeded(newClass, tree.varargsElement);
        return newClass;
    }
}
 
Example #5
Source File: LambdaToMethod.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Lambda body to use for a 'new'.
 */
private JCExpression expressionNew() {
    if (tree.kind == ReferenceKind.ARRAY_CTOR) {
        //create the array creation expression
        JCNewArray newArr = make.NewArray(
                make.Type(types.elemtype(tree.getQualifierExpression().type)),
                List.of(make.Ident(params.first())),
                null);
        newArr.type = tree.getQualifierExpression().type;
        return newArr;
    } else {
        //create the instance creation expression
        //note that method reference syntax does not allow an explicit
        //enclosing class (so the enclosing class is null)
        JCNewClass newClass = make.NewClass(null,
                List.<JCExpression>nil(),
                make.Type(tree.getQualifierExpression().type),
                convertArgs(tree.sym, args.toList(), tree.varargsElement),
                null);
        newClass.constructor = tree.sym;
        newClass.constructorType = tree.sym.erasure(types);
        newClass.type = tree.getQualifierExpression().type;
        setVarargsIfNeeded(newClass, tree.varargsElement);
        return newClass;
    }
}
 
Example #6
Source File: LambdaToMethod.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Erasure destroys the implementation parameter subtype
 * relationship for intersection types
 */
boolean interfaceParameterIsIntersectionType() {
    List<Type> tl = tree.getDescriptorType(types).getParameterTypes();
    if (tree.kind == ReferenceKind.UNBOUND) {
        tl = tl.tail;
    }
    for (; tl.nonEmpty(); tl = tl.tail) {
        Type pt = tl.head;
        if (pt.getKind() == TypeKind.TYPEVAR) {
            TypeVar tv = (TypeVar) pt;
            if (tv.bound.getKind() == TypeKind.INTERSECTION) {
                return true;
            }
        }
    }
    return false;
}
 
Example #7
Source File: LambdaToMethod.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Lambda body to use for a 'new'.
 */
private JCExpression expressionNew() {
    if (tree.kind == ReferenceKind.ARRAY_CTOR) {
        //create the array creation expression
        JCNewArray newArr = make.NewArray(
                make.Type(types.elemtype(tree.getQualifierExpression().type)),
                List.of(make.Ident(params.first())),
                null);
        newArr.type = tree.getQualifierExpression().type;
        return newArr;
    } else {
        //create the instance creation expression
        //note that method reference syntax does not allow an explicit
        //enclosing class (so the enclosing class is null)
        JCNewClass newClass = make.NewClass(null,
                List.<JCExpression>nil(),
                make.Type(tree.getQualifierExpression().type),
                convertArgs(tree.sym, args.toList(), tree.varargsElement),
                null);
        newClass.constructor = tree.sym;
        newClass.constructorType = tree.sym.erasure(types);
        newClass.type = tree.getQualifierExpression().type;
        setVarargsIfNeeded(newClass, tree.varargsElement);
        return newClass;
    }
}
 
Example #8
Source File: LambdaToMethod.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Erasure destroys the implementation parameter subtype
 * relationship for intersection types
 */
boolean interfaceParameterIsIntersectionType() {
    List<Type> tl = tree.getDescriptorType(types).getParameterTypes();
    if (tree.kind == ReferenceKind.UNBOUND) {
        tl = tl.tail;
    }
    for (; tl.nonEmpty(); tl = tl.tail) {
        Type pt = tl.head;
        if (pt.getKind() == TypeKind.TYPEVAR) {
            TypeVar tv = (TypeVar) pt;
            if (tv.bound.getKind() == TypeKind.INTERSECTION) {
                return true;
            }
        }
    }
    return false;
}
 
Example #9
Source File: LambdaToMethod.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Lambda body to use for a 'new'.
 */
private JCExpression expressionNew() {
    if (tree.kind == ReferenceKind.ARRAY_CTOR) {
        //create the array creation expression
        JCNewArray newArr = make.NewArray(
                make.Type(types.elemtype(tree.getQualifierExpression().type)),
                List.of(make.Ident(params.first())),
                null);
        newArr.type = tree.getQualifierExpression().type;
        return newArr;
    } else {
        //create the instance creation expression
        //note that method reference syntax does not allow an explicit
        //enclosing class (so the enclosing class is null)
        JCNewClass newClass = make.NewClass(null,
                List.nil(),
                make.Type(tree.getQualifierExpression().type),
                convertArgs(tree.sym, args.toList(), tree.varargsElement),
                null);
        newClass.constructor = tree.sym;
        newClass.constructorType = tree.sym.erasure(types);
        newClass.type = tree.getQualifierExpression().type;
        setVarargsIfNeeded(newClass, tree.varargsElement);
        return newClass;
    }
}
 
Example #10
Source File: LambdaToMethod.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Erasure destroys the implementation parameter subtype
 * relationship for intersection types
 */
boolean interfaceParameterIsIntersectionType() {
    List<Type> tl = tree.getDescriptorType(types).getParameterTypes();
    if (tree.kind == ReferenceKind.UNBOUND) {
        tl = tl.tail;
    }
    for (; tl.nonEmpty(); tl = tl.tail) {
        Type pt = tl.head;
        if (pt.getKind() == TypeKind.TYPEVAR) {
            TypeVar tv = (TypeVar) pt;
            if (tv.bound.getKind() == TypeKind.INTERSECTION) {
                return true;
            }
        }
    }
    return false;
}
 
Example #11
Source File: LambdaToMethod.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Lambda body to use for a 'new'.
 */
private JCExpression expressionNew() {
    if (tree.kind == ReferenceKind.ARRAY_CTOR) {
        //create the array creation expression
        JCNewArray newArr = make.NewArray(
                make.Type(types.elemtype(tree.getQualifierExpression().type)),
                List.of(make.Ident(params.first())),
                null);
        newArr.type = tree.getQualifierExpression().type;
        return newArr;
    } else {
        //create the instance creation expression
        //note that method reference syntax does not allow an explicit
        //enclosing class (so the enclosing class is null)
        JCNewClass newClass = make.NewClass(null,
                List.nil(),
                make.Type(tree.getQualifierExpression().type),
                convertArgs(tree.sym, args.toList(), tree.varargsElement),
                null);
        newClass.constructor = tree.sym;
        newClass.constructorType = tree.sym.erasure(types);
        newClass.type = tree.getQualifierExpression().type;
        setVarargsIfNeeded(newClass, tree.varargsElement);
        return newClass;
    }
}
 
Example #12
Source File: LambdaToMethod.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Lambda body to use for a 'new'.
 */
private JCExpression expressionNew() {
    if (tree.kind == ReferenceKind.ARRAY_CTOR) {
        //create the array creation expression
        JCNewArray newArr = make.NewArray(
                make.Type(types.elemtype(tree.getQualifierExpression().type)),
                List.of(make.Ident(params.first())),
                null);
        newArr.type = tree.getQualifierExpression().type;
        return newArr;
    } else {
        //create the instance creation expression
        //note that method reference syntax does not allow an explicit
        //enclosing class (so the enclosing class is null)
        JCNewClass newClass = make.NewClass(null,
                List.<JCExpression>nil(),
                make.Type(tree.getQualifierExpression().type),
                convertArgs(tree.sym, args.toList(), tree.varargsElement),
                null);
        newClass.constructor = tree.sym;
        newClass.constructorType = tree.sym.erasure(types);
        newClass.type = tree.getQualifierExpression().type;
        setVarargsIfNeeded(newClass, tree.varargsElement);
        return newClass;
    }
}
 
Example #13
Source File: LambdaToMethod.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Erasure destroys the implementation parameter subtype
 * relationship for intersection types
 */
boolean interfaceParameterIsIntersectionType() {
    List<Type> tl = tree.getDescriptorType(types).getParameterTypes();
    if (tree.kind == ReferenceKind.UNBOUND) {
        tl = tl.tail;
    }
    for (; tl.nonEmpty(); tl = tl.tail) {
        Type pt = tl.head;
        if (pt.getKind() == TypeKind.TYPEVAR) {
            TypeVar tv = (TypeVar) pt;
            if (tv.bound.getKind() == TypeKind.INTERSECTION) {
                return true;
            }
        }
    }
    return false;
}
 
Example #14
Source File: LambdaToMethod.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
ReferenceTranslationContext(JCMemberReference tree) {
    super(tree);
    this.isSuper = tree.hasKind(ReferenceKind.SUPER);
    this.bridgeSym = needsBridge()
            ? makePrivateSyntheticMethod(isSuper ? 0 : STATIC,
                                  referenceBridgeName(), null,
                                  owner.enclClass())
            : null;
    this.sigPolySym = isSignaturePolymorphic()
            ? makePrivateSyntheticMethod(tree.sym.flags(),
                                  tree.sym.name,
                                  bridgedRefSig(),
                                  tree.sym.enclClass())
            : null;
    if (dumpLambdaToMethodStats) {
        String key = bridgeSym == null ?
                "mref.stat" : "mref.stat.1";
        log.note(tree, key, needsAltMetafactory(), bridgeSym);
    }
}
 
Example #15
Source File: Resolve.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceKind referenceKind(Symbol sym) {
    if (sym.isStatic()) {
        return ReferenceKind.STATIC;
    } else {
        Name selName = TreeInfo.name(referenceTree.getQualifierExpression());
        return selName != null && selName == names._super ?
                ReferenceKind.SUPER :
                ReferenceKind.BOUND;
    }
}
 
Example #16
Source File: Resolve.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceKind referenceKind(Symbol sym) {
    if (sym.isStatic()) {
        return ReferenceKind.STATIC;
    } else {
        Name selName = TreeInfo.name(referenceTree.getQualifierExpression());
        return selName != null && selName == names._super ?
                ReferenceKind.SUPER :
                ReferenceKind.BOUND;
    }
}
 
Example #17
Source File: LambdaToMethod.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
ReferenceTranslationContext(JCMemberReference tree) {
    super(tree);
    this.isSuper = tree.hasKind(ReferenceKind.SUPER);
    this.sigPolySym = isSignaturePolymorphic()
            ? makePrivateSyntheticMethod(tree.sym.flags(),
                                  tree.sym.name,
                                  bridgedRefSig(),
                                  tree.sym.enclClass())
            : null;
}
 
Example #18
Source File: LambdaToMethod.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * the enclosing expression is either 'null' (no enclosing type) or set
 * to the first bridge synthetic parameter
 */
private JCExpression bridgeExpressionNew() {
    if (tree.kind == ReferenceKind.ARRAY_CTOR) {
        //create the array creation expression
        JCNewArray newArr = make.NewArray(
                make.Type(types.elemtype(tree.getQualifierExpression().type)),
                List.of(make.Ident(params.first())),
                null);
        newArr.type = tree.getQualifierExpression().type;
        return newArr;
    } else {
        JCExpression encl = null;
        switch (tree.kind) {
            case UNBOUND:
            case IMPLICIT_INNER:
                encl = make.Ident(params.first());
        }

        //create the instance creation expression
        JCNewClass newClass = make.NewClass(encl,
                List.<JCExpression>nil(),
                make.Type(tree.getQualifierExpression().type),
                convertArgs(tree.sym, args.toList(), tree.varargsElement),
                null);
        newClass.constructor = tree.sym;
        newClass.constructorType = tree.sym.erasure(types);
        newClass.type = tree.getQualifierExpression().type;
        setVarargsIfNeeded(newClass, tree.varargsElement);
        return newClass;
    }
}
 
Example #19
Source File: Resolve.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceKind referenceKind(Symbol sym) {
    if (sym.isStatic()) {
        return ReferenceKind.STATIC;
    } else {
        Name selName = TreeInfo.name(referenceTree.getQualifierExpression());
        return selName != null && selName == names._super ?
                ReferenceKind.SUPER :
                ReferenceKind.BOUND;
    }
}
 
Example #20
Source File: LambdaToMethod.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Does this reference need to be converted to a lambda
 * (i.e. var args need to be expanded or "super" is used)
 */
final boolean needsConversionToLambda() {
    return interfaceParameterIsIntersectionType() ||
            isSuper ||
            needsVarArgsConversion() ||
            isArrayOp() ||
            isPrivateInOtherClass() ||
            !receiverAccessible() ||
            (tree.getMode() == ReferenceMode.NEW &&
              tree.kind != ReferenceKind.ARRAY_CTOR &&
              (tree.sym.owner.isLocal() || tree.sym.owner.isInner()));
}
 
Example #21
Source File: LambdaToMethod.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * the enclosing expression is either 'null' (no enclosing type) or set
 * to the first bridge synthetic parameter
 */
private JCExpression bridgeExpressionNew() {
    if (tree.kind == ReferenceKind.ARRAY_CTOR) {
        //create the array creation expression
        JCNewArray newArr = make.NewArray(
                make.Type(types.elemtype(tree.getQualifierExpression().type)),
                List.of(make.Ident(params.first())),
                null);
        newArr.type = tree.getQualifierExpression().type;
        return newArr;
    } else {
        JCExpression encl = null;
        switch (tree.kind) {
            case UNBOUND:
            case IMPLICIT_INNER:
                encl = make.Ident(params.first());
        }

        //create the instance creation expression
        JCNewClass newClass = make.NewClass(encl,
                List.<JCExpression>nil(),
                make.Type(tree.getQualifierExpression().type),
                convertArgs(tree.sym, args.toList(), tree.varargsElement),
                null);
        newClass.constructor = tree.sym;
        newClass.constructorType = tree.sym.erasure(types);
        newClass.type = tree.getQualifierExpression().type;
        setVarargsIfNeeded(newClass, tree.varargsElement);
        return newClass;
    }
}
 
Example #22
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceKind referenceKind(Symbol sym) {
    if (sym.isStatic()) {
        return ReferenceKind.STATIC;
    } else {
        Name selName = TreeInfo.name(referenceTree.getQualifierExpression());
        return selName != null && selName == names._super ?
                ReferenceKind.SUPER :
                ReferenceKind.BOUND;
    }
}
 
Example #23
Source File: Resolve.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceKind referenceKind(Symbol sym) {
    if (sym.isStatic()) {
        return ReferenceKind.STATIC;
    } else {
        Name selName = TreeInfo.name(referenceTree.getQualifierExpression());
        return selName != null && selName == names._super ?
                ReferenceKind.SUPER :
                ReferenceKind.BOUND;
    }
}
 
Example #24
Source File: LambdaToMethod.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
ReferenceTranslationContext(JCMemberReference tree) {
    super(tree);
    this.isSuper = tree.hasKind(ReferenceKind.SUPER);
    this.sigPolySym = isSignaturePolymorphic()
            ? makePrivateSyntheticMethod(tree.sym.flags(),
                                  tree.sym.name,
                                  bridgedRefSig(),
                                  tree.sym.enclClass())
            : null;
}
 
Example #25
Source File: TransTypes.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void visitReference(JCMemberReference tree) {
    Type t = types.skipTypeVars(tree.expr.type, false);
    Type receiverTarget = t.isCompound() ? erasure(tree.sym.owner.type) : erasure(t);
    if (tree.kind == ReferenceKind.UNBOUND) {
        tree.expr = make.Type(receiverTarget);
    } else {
        tree.expr = translate(tree.expr, receiverTarget);
    }

    tree.type = erasure(tree.type);
    if (tree.varargsElement != null)
        tree.varargsElement = erasure(tree.varargsElement);
    result = tree;
}
 
Example #26
Source File: LambdaToMethod.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Does this reference need to be converted to a lambda
 * (i.e. var args need to be expanded or "super" is used)
 */
final boolean needsConversionToLambda() {
    return interfaceParameterIsIntersectionType() ||
            isSuper ||
            needsVarArgsConversion() ||
            isArrayOp() ||
            isPrivateInOtherClass() ||
            !receiverAccessible() ||
            (tree.getMode() == ReferenceMode.NEW &&
              tree.kind != ReferenceKind.ARRAY_CTOR &&
              (tree.sym.owner.isLocal() || tree.sym.owner.isInner()));
}
 
Example #27
Source File: LambdaToMethod.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
ReferenceTranslationContext(JCMemberReference tree) {
    super(tree);
    this.isSuper = tree.hasKind(ReferenceKind.SUPER);
    this.sigPolySym = isSignaturePolymorphic()
            ? makePrivateSyntheticMethod(tree.sym.flags(),
                                  tree.sym.name,
                                  bridgedRefSig(),
                                  tree.sym.enclClass())
            : null;
}
 
Example #28
Source File: LambdaToMethod.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
ReferenceTranslationContext(JCMemberReference tree) {
    super(tree);
    this.isSuper = tree.hasKind(ReferenceKind.SUPER);
    this.sigPolySym = isSignaturePolymorphic()
            ? makePrivateSyntheticMethod(tree.sym.flags(),
                                  tree.sym.name,
                                  bridgedRefSig(),
                                  tree.sym.enclClass())
            : null;
}
 
Example #29
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceKind referenceKind(Symbol sym) {
    if (sym.isStatic()) {
        return ReferenceKind.STATIC;
    } else {
        Name selName = TreeInfo.name(referenceTree.getQualifierExpression());
        return selName != null && selName == names._super ?
                ReferenceKind.SUPER :
                ReferenceKind.BOUND;
    }
}
 
Example #30
Source File: LambdaToMethod.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Does this reference need to be converted to a lambda
 * (i.e. var args need to be expanded or "super" is used)
 */
final boolean needsConversionToLambda() {
    return interfaceParameterIsIntersectionType() ||
            isSuper ||
            needsVarArgsConversion() ||
            isArrayOp() ||
            isPrivateInOtherClass() ||
            isProtectedInSuperClassOfEnclosingClassInOtherPackage() ||
            !receiverAccessible() ||
            (tree.getMode() == ReferenceMode.NEW &&
              tree.kind != ReferenceKind.ARRAY_CTOR &&
              (tree.sym.owner.isLocal() || tree.sym.owner.isInner()));
}