Java Code Examples for com.sun.tools.javac.util.List#append()

The following examples show how to use com.sun.tools.javac.util.List#append() . 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: TransTypes.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge,
        Type bridgeType) {
    List<VarSymbol> bridgeParams = null;
    if (impl.params != null) {
        bridgeParams = List.nil();
        List<VarSymbol> implParams = impl.params;
        Type.MethodType mType = (Type.MethodType)bridgeType;
        List<Type> argTypes = mType.argtypes;
        while (implParams.nonEmpty() && argTypes.nonEmpty()) {
            VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER,
                    implParams.head.name, argTypes.head, bridge);
            param.setAttributes(implParams.head);
            bridgeParams = bridgeParams.append(param);
            implParams = implParams.tail;
            argTypes = argTypes.tail;
        }
    }
    return bridgeParams;
}
 
Example 2
Source File: TransTypes.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge,
        Type bridgeType) {
    List<VarSymbol> bridgeParams = null;
    if (impl.params != null) {
        bridgeParams = List.nil();
        List<VarSymbol> implParams = impl.params;
        Type.MethodType mType = (Type.MethodType)bridgeType;
        List<Type> argTypes = mType.argtypes;
        while (implParams.nonEmpty() && argTypes.nonEmpty()) {
            VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER,
                    implParams.head.name, argTypes.head, bridge);
            param.setAttributes(implParams.head);
            bridgeParams = bridgeParams.append(param);
            implParams = implParams.tail;
            argTypes = argTypes.tail;
        }
    }
    return bridgeParams;
}
 
Example 3
Source File: TransTypes.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge,
        Type bridgeType) {
    List<VarSymbol> bridgeParams = null;
    if (impl.params != null) {
        bridgeParams = List.nil();
        List<VarSymbol> implParams = impl.params;
        Type.MethodType mType = (Type.MethodType)bridgeType;
        List<Type> argTypes = mType.argtypes;
        while (implParams.nonEmpty() && argTypes.nonEmpty()) {
            VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER,
                    implParams.head.name, argTypes.head, bridge);
            param.setAttributes(implParams.head);
            bridgeParams = bridgeParams.append(param);
            implParams = implParams.tail;
            argTypes = argTypes.tail;
        }
    }
    return bridgeParams;
}
 
Example 4
Source File: JavacHandlerUtil.java    From EasyMPermission with MIT License 6 votes vote down vote up
public static void sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(JavacNode typeNode, JavacNode errorNode) {
	List<String> disallowed = List.nil();
	for (JavacNode child : typeNode.down()) {
		for (Class<? extends java.lang.annotation.Annotation> annType : INVALID_ON_BUILDERS) {
			if (annotationTypeMatches(annType, child)) {
				disallowed = disallowed.append(annType.getSimpleName());
			}
		}
	}
	
	int size = disallowed.size();
	if (size == 0) return;
	if (size == 1) {
		errorNode.addError("@" + disallowed.head + " is not allowed on builder classes.");
		return;
	}
	StringBuilder out = new StringBuilder();
	for (String a : disallowed) out.append("@").append(a).append(", ");
	out.setLength(out.length() - 2);
	errorNode.addError(out.append(" are not allowed on builder classes.").toString());
}
 
Example 5
Source File: TransTypes.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge,
        Type bridgeType) {
    List<VarSymbol> bridgeParams = null;
    if (impl.params != null) {
        bridgeParams = List.nil();
        List<VarSymbol> implParams = impl.params;
        Type.MethodType mType = (Type.MethodType)bridgeType;
        List<Type> argTypes = mType.argtypes;
        while (implParams.nonEmpty() && argTypes.nonEmpty()) {
            VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER,
                    implParams.head.name, argTypes.head, bridge);
            param.setAttributes(implParams.head);
            bridgeParams = bridgeParams.append(param);
            implParams = implParams.tail;
            argTypes = argTypes.tail;
        }
    }
    return bridgeParams;
}
 
Example 6
Source File: TransTypes.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge,
        Type bridgeType) {
    List<VarSymbol> bridgeParams = null;
    if (impl.params != null) {
        bridgeParams = List.nil();
        List<VarSymbol> implParams = impl.params;
        Type.MethodType mType = (Type.MethodType)bridgeType;
        List<Type> argTypes = mType.argtypes;
        while (implParams.nonEmpty() && argTypes.nonEmpty()) {
            VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER,
                    implParams.head.name, argTypes.head, bridge);
            param.setAttributes(implParams.head);
            bridgeParams = bridgeParams.append(param);
            implParams = implParams.tail;
            argTypes = argTypes.tail;
        }
    }
    return bridgeParams;
}
 
Example 7
Source File: TransTypes.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge,
        Type bridgeType) {
    List<VarSymbol> bridgeParams = null;
    if (impl.params != null) {
        bridgeParams = List.nil();
        List<VarSymbol> implParams = impl.params;
        Type.MethodType mType = (Type.MethodType)bridgeType;
        List<Type> argTypes = mType.argtypes;
        while (implParams.nonEmpty() && argTypes.nonEmpty()) {
            VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER,
                    implParams.head.name, argTypes.head, bridge);
            param.setAttributes(implParams.head);
            bridgeParams = bridgeParams.append(param);
            implParams = implParams.tail;
            argTypes = argTypes.tail;
        }
    }
    return bridgeParams;
}
 
Example 8
Source File: TransTypes.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge,
        Type bridgeType) {
    List<VarSymbol> bridgeParams = null;
    if (impl.params != null) {
        bridgeParams = List.nil();
        List<VarSymbol> implParams = impl.params;
        Type.MethodType mType = (Type.MethodType)bridgeType;
        List<Type> argTypes = mType.argtypes;
        while (implParams.nonEmpty() && argTypes.nonEmpty()) {
            VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER,
                    implParams.head.name, argTypes.head, bridge);
            param.setAttributes(implParams.head);
            bridgeParams = bridgeParams.append(param);
            implParams = implParams.tail;
            argTypes = argTypes.tail;
        }
    }
    return bridgeParams;
}
 
Example 9
Source File: Lower.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** Return access constructor for a private constructor,
 *  or the constructor itself, if no access constructor is needed.
 *  @param pos       The position to report diagnostics, if any.
 *  @param constr    The private constructor.
 */
Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
    if (needsPrivateAccess(constr)) {
        ClassSymbol accOwner = constr.owner.enclClass();
        MethodSymbol aconstr = accessConstrs.get(constr);
        if (aconstr == null) {
            List<Type> argtypes = constr.type.getParameterTypes();
            if ((accOwner.flags_field & ENUM) != 0)
                argtypes = argtypes
                    .prepend(syms.intType)
                    .prepend(syms.stringType);
            aconstr = new MethodSymbol(
                SYNTHETIC,
                names.init,
                new MethodType(
                    argtypes.append(
                        accessConstructorTag().erasure(types)),
                    constr.type.getReturnType(),
                    constr.type.getThrownTypes(),
                    syms.methodClass),
                accOwner);
            enterSynthetic(pos, aconstr, accOwner.members());
            accessConstrs.put(constr, aconstr);
            accessed.append(constr);
        }
        return aconstr;
    } else {
        return constr;
    }
}
 
Example 10
Source File: StringConcat.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private List<JCTree> collect(JCTree tree, List<JCTree> res) {
    tree = TreeInfo.skipParens(tree);
    if (tree.hasTag(PLUS) && tree.type.constValue() == null) {
        JCTree.JCBinary op = (JCTree.JCBinary) tree;
        if (op.operator.kind == MTH && op.operator.opcode == string_add) {
            return res
                    .appendList(collect(op.lhs, res))
                    .appendList(collect(op.rhs, res));
        }
    }
    return res.append(tree);
}
 
Example 11
Source File: Lower.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/** Return access constructor for a private constructor,
 *  or the constructor itself, if no access constructor is needed.
 *  @param pos       The position to report diagnostics, if any.
 *  @param constr    The private constructor.
 */
Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
    if (needsPrivateAccess(constr)) {
        ClassSymbol accOwner = constr.owner.enclClass();
        MethodSymbol aconstr = accessConstrs.get(constr);
        if (aconstr == null) {
            List<Type> argtypes = constr.type.getParameterTypes();
            if ((accOwner.flags_field & ENUM) != 0)
                argtypes = argtypes
                    .prepend(syms.intType)
                    .prepend(syms.stringType);
            aconstr = new MethodSymbol(
                SYNTHETIC,
                names.init,
                new MethodType(
                    argtypes.append(
                        accessConstructorTag().erasure(types)),
                    constr.type.getReturnType(),
                    constr.type.getThrownTypes(),
                    syms.methodClass),
                accOwner);
            enterSynthetic(pos, aconstr, accOwner.members());
            accessConstrs.put(constr, aconstr);
            accessed.append(constr);
        }
        return aconstr;
    } else {
        return constr;
    }
}
 
Example 12
Source File: Lower.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** Return access constructor for a private constructor,
 *  or the constructor itself, if no access constructor is needed.
 *  @param pos       The position to report diagnostics, if any.
 *  @param constr    The private constructor.
 */
Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
    if (needsPrivateAccess(constr)) {
        ClassSymbol accOwner = constr.owner.enclClass();
        MethodSymbol aconstr = accessConstrs.get(constr);
        if (aconstr == null) {
            List<Type> argtypes = constr.type.getParameterTypes();
            if ((accOwner.flags_field & ENUM) != 0)
                argtypes = argtypes
                    .prepend(syms.intType)
                    .prepend(syms.stringType);
            aconstr = new MethodSymbol(
                SYNTHETIC,
                names.init,
                new MethodType(
                    argtypes.append(
                        accessConstructorTag().erasure(types)),
                    constr.type.getReturnType(),
                    constr.type.getThrownTypes(),
                    syms.methodClass),
                accOwner);
            enterSynthetic(pos, aconstr, accOwner.members());
            accessConstrs.put(constr, aconstr);
            accessed.append(constr);
        }
        return aconstr;
    } else {
        return constr;
    }
}
 
Example 13
Source File: Lower.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/** Return access constructor for a private constructor,
 *  or the constructor itself, if no access constructor is needed.
 *  @param pos       The position to report diagnostics, if any.
 *  @param constr    The private constructor.
 */
Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
    if (needsPrivateAccess(constr)) {
        ClassSymbol accOwner = constr.owner.enclClass();
        MethodSymbol aconstr = accessConstrs.get(constr);
        if (aconstr == null) {
            List<Type> argtypes = constr.type.getParameterTypes();
            if ((accOwner.flags_field & ENUM) != 0)
                argtypes = argtypes
                    .prepend(syms.intType)
                    .prepend(syms.stringType);
            aconstr = new MethodSymbol(
                SYNTHETIC,
                names.init,
                new MethodType(
                    argtypes.append(
                        accessConstructorTag().erasure(types)),
                    constr.type.getReturnType(),
                    constr.type.getThrownTypes(),
                    syms.methodClass),
                accOwner);
            enterSynthetic(pos, aconstr, accOwner.members());
            accessConstrs.put(constr, aconstr);
            accessed.append(constr);
        }
        return aconstr;
    } else {
        return constr;
    }
}
 
Example 14
Source File: Lower.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Return access constructor for a private constructor,
 *  or the constructor itself, if no access constructor is needed.
 *  @param pos       The position to report diagnostics, if any.
 *  @param constr    The private constructor.
 */
Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
    if (needsPrivateAccess(constr)) {
        ClassSymbol accOwner = constr.owner.enclClass();
        MethodSymbol aconstr = accessConstrs.get(constr);
        if (aconstr == null) {
            List<Type> argtypes = constr.type.getParameterTypes();
            if ((accOwner.flags_field & ENUM) != 0)
                argtypes = argtypes
                    .prepend(syms.intType)
                    .prepend(syms.stringType);
            aconstr = new MethodSymbol(
                SYNTHETIC,
                names.init,
                new MethodType(
                    argtypes.append(
                        accessConstructorTag().erasure(types)),
                    constr.type.getReturnType(),
                    constr.type.getThrownTypes(),
                    syms.methodClass),
                accOwner);
            enterSynthetic(pos, aconstr, accOwner.members());
            accessConstrs.put(constr, aconstr);
            accessed.append(constr);
        }
        return aconstr;
    } else {
        return constr;
    }
}
 
Example 15
Source File: Lower.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Return access constructor for a private constructor,
 *  or the constructor itself, if no access constructor is needed.
 *  @param pos       The position to report diagnostics, if any.
 *  @param constr    The private constructor.
 */
Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
    if (needsPrivateAccess(constr)) {
        ClassSymbol accOwner = constr.owner.enclClass();
        MethodSymbol aconstr = accessConstrs.get(constr);
        if (aconstr == null) {
            List<Type> argtypes = constr.type.getParameterTypes();
            if ((accOwner.flags_field & ENUM) != 0)
                argtypes = argtypes
                    .prepend(syms.intType)
                    .prepend(syms.stringType);
            aconstr = new MethodSymbol(
                SYNTHETIC,
                names.init,
                new MethodType(
                    argtypes.append(
                        accessConstructorTag().erasure(types)),
                    constr.type.getReturnType(),
                    constr.type.getThrownTypes(),
                    syms.methodClass),
                accOwner);
            enterSynthetic(pos, aconstr, accOwner.members());
            accessConstrs.put(constr, aconstr);
            accessed.append(constr);
        }
        return aconstr;
    } else {
        return constr;
    }
}
 
Example 16
Source File: Lower.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** Return access constructor for a private constructor,
 *  or the constructor itself, if no access constructor is needed.
 *  @param pos       The position to report diagnostics, if any.
 *  @param constr    The private constructor.
 */
Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
    if (needsPrivateAccess(constr)) {
        ClassSymbol accOwner = constr.owner.enclClass();
        MethodSymbol aconstr = accessConstrs.get(constr);
        if (aconstr == null) {
            List<Type> argtypes = constr.type.getParameterTypes();
            if ((accOwner.flags_field & ENUM) != 0)
                argtypes = argtypes
                    .prepend(syms.intType)
                    .prepend(syms.stringType);
            aconstr = new MethodSymbol(
                SYNTHETIC,
                names.init,
                new MethodType(
                    argtypes.append(
                        accessConstructorTag().erasure(types)),
                    constr.type.getReturnType(),
                    constr.type.getThrownTypes(),
                    syms.methodClass),
                accOwner);
            enterSynthetic(pos, aconstr, accOwner.members());
            accessConstrs.put(constr, aconstr);
            accessed.append(constr);
        }
        return aconstr;
    } else {
        return constr;
    }
}
 
Example 17
Source File: Lower.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** Return access constructor for a private constructor,
 *  or the constructor itself, if no access constructor is needed.
 *  @param pos       The position to report diagnostics, if any.
 *  @param constr    The private constructor.
 */
Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
    if (needsPrivateAccess(constr)) {
        ClassSymbol accOwner = constr.owner.enclClass();
        MethodSymbol aconstr = accessConstrs.get(constr);
        if (aconstr == null) {
            List<Type> argtypes = constr.type.getParameterTypes();
            if ((accOwner.flags_field & ENUM) != 0)
                argtypes = argtypes
                    .prepend(syms.intType)
                    .prepend(syms.stringType);
            aconstr = new MethodSymbol(
                SYNTHETIC,
                names.init,
                new MethodType(
                    argtypes.append(
                        accessConstructorTag().erasure(types)),
                    constr.type.getReturnType(),
                    constr.type.getThrownTypes(),
                    syms.methodClass),
                accOwner);
            enterSynthetic(pos, aconstr, accOwner.members());
            accessConstrs.put(constr, aconstr);
            accessed.append(constr);
        }
        return aconstr;
    } else {
        return constr;
    }
}
 
Example 18
Source File: Lower.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** Return access constructor for a private constructor,
 *  or the constructor itself, if no access constructor is needed.
 *  @param pos       The position to report diagnostics, if any.
 *  @param constr    The private constructor.
 */
Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
    if (needsPrivateAccess(constr)) {
        ClassSymbol accOwner = constr.owner.enclClass();
        MethodSymbol aconstr = accessConstrs.get(constr);
        if (aconstr == null) {
            List<Type> argtypes = constr.type.getParameterTypes();
            if ((accOwner.flags_field & ENUM) != 0)
                argtypes = argtypes
                    .prepend(syms.intType)
                    .prepend(syms.stringType);
            aconstr = new MethodSymbol(
                SYNTHETIC,
                names.init,
                new MethodType(
                    argtypes.append(
                        accessConstructorTag().erasure(types)),
                    constr.type.getReturnType(),
                    constr.type.getThrownTypes(),
                    syms.methodClass),
                accOwner);
            enterSynthetic(pos, aconstr, accOwner.members());
            accessConstrs.put(constr, aconstr);
            accessed.append(constr);
        }
        return aconstr;
    } else {
        return constr;
    }
}
 
Example 19
Source File: Inliner.java    From Refaster with Apache License 2.0 5 votes vote down vote up
@Override
public JCExpression visitClassType(ClassType type, Inliner inliner) {
  ClassSymbol classSym = (ClassSymbol) type.tsym;
  JCExpression classExpr = inliner.importPolicy().classReference(
      inliner, classSym.outermostClass().getQualifiedName().toString(),
      classSym.getQualifiedName().toString());
  List<JCExpression> argExprs = List.nil();
  for (Type argType : type.getTypeArguments()) {
    argExprs = argExprs.append(visit(argType, inliner));
  }
  return argExprs.isEmpty()
      ? classExpr
      : inliner.maker().TypeApply(classExpr, argExprs);
}
 
Example 20
Source File: LambdaToMethod.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Generate an indy method call to the meta factory
 */
private JCExpression makeMetafactoryIndyCall(TranslationContext<?> context,
        int refKind, Symbol refSym, List<JCExpression> indy_args) {
    JCFunctionalExpression tree = context.tree;
    //determine the static bsm args
    MethodSymbol samSym = (MethodSymbol) types.findDescriptorSymbol(tree.type.tsym);
    List<Object> staticArgs = List.of(
            typeToMethodType(samSym.type),
            new Pool.MethodHandle(refKind, refSym, types),
            typeToMethodType(tree.getDescriptorType(types)));

    //computed indy arg types
    ListBuffer<Type> indy_args_types = new ListBuffer<>();
    for (JCExpression arg : indy_args) {
        indy_args_types.append(arg.type);
    }

    //finally, compute the type of the indy call
    MethodType indyType = new MethodType(indy_args_types.toList(),
            tree.type,
            List.nil(),
            syms.methodClass);

    Name metafactoryName = context.needsAltMetafactory() ?
            names.altMetafactory : names.metafactory;

    if (context.needsAltMetafactory()) {
        ListBuffer<Object> markers = new ListBuffer<>();
        for (Type t : tree.targets.tail) {
            if (t.tsym != syms.serializableType.tsym) {
                markers.append(t.tsym);
            }
        }
        int flags = context.isSerializable() ? FLAG_SERIALIZABLE : 0;
        boolean hasMarkers = markers.nonEmpty();
        boolean hasBridges = context.bridges.nonEmpty();
        if (hasMarkers) {
            flags |= FLAG_MARKERS;
        }
        if (hasBridges) {
            flags |= FLAG_BRIDGES;
        }
        staticArgs = staticArgs.append(flags);
        if (hasMarkers) {
            staticArgs = staticArgs.append(markers.length());
            staticArgs = staticArgs.appendList(markers.toList());
        }
        if (hasBridges) {
            staticArgs = staticArgs.append(context.bridges.length() - 1);
            for (Symbol s : context.bridges) {
                Type s_erasure = s.erasure(types);
                if (!types.isSameType(s_erasure, samSym.erasure(types))) {
                    staticArgs = staticArgs.append(s.erasure(types));
                }
            }
        }
        if (context.isSerializable()) {
            int prevPos = make.pos;
            try {
                make.at(kInfo.clazz);
                addDeserializationCase(refKind, refSym, tree.type, samSym,
                        tree, staticArgs, indyType);
            } finally {
                make.at(prevPos);
            }
        }
    }

    return makeIndyCall(tree, syms.lambdaMetafactory, metafactoryName, staticArgs, indyType, indy_args, samSym.name);
}