com.sun.tools.javac.code.Type.ArrayType Java Examples

The following examples show how to use com.sun.tools.javac.code.Type.ArrayType. 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: Printer.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuffer buf = new StringBuffer();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.tag == ARRAY) {
            buf.append(visit(((ArrayType) args.head).elemtype, locale));
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #2
Source File: Printer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #3
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Check that type is a valid qualifier for a constructor reference expression
 */
Type checkConstructorRefType(DiagnosticPosition pos, Type t) {
    t = checkClassOrArrayType(pos, t);
    if (t.hasTag(CLASS)) {
        if ((t.tsym.flags() & (ABSTRACT | INTERFACE)) != 0) {
            log.error(pos, Errors.AbstractCantBeInstantiated(t.tsym));
            t = types.createErrorType(t);
        } else if ((t.tsym.flags() & ENUM) != 0) {
            log.error(pos, Errors.EnumCantBeInstantiated);
            t = types.createErrorType(t);
        } else {
            t = checkClassType(pos, t, true);
        }
    } else if (t.hasTag(ARRAY)) {
        if (!types.isReifiable(((ArrayType)t).elemtype)) {
            log.error(pos, Errors.GenericArrayCreation);
            t = types.createErrorType(t);
        }
    }
    return t;
}
 
Example #4
Source File: Printer.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #5
Source File: Printer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #6
Source File: TypeMaker.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static String getTypeName(Type t, boolean full) {
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = ((ArrayType)t).elemtype;
        }
        s.insert(0, getTypeName(t, full));
        return s.toString();
    case CLASS:
        return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example #7
Source File: TypeMaker.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static String getTypeName(Type t, boolean full) {
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = ((ArrayType)t).elemtype;
        }
        s.insert(0, getTypeName(t, full));
        return s.toString();
    case CLASS:
        return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example #8
Source File: Printer.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuffer buf = new StringBuffer();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.tag == ARRAY) {
            buf.append(visit(((ArrayType) args.head).elemtype, locale));
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #9
Source File: TypeMaker.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static String getTypeName(Type t, boolean full) {
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = ((ArrayType)t).elemtype;
        }
        s.insert(0, getTypeName(t, full));
        return s.toString();
    case CLASS:
        return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example #10
Source File: Lower.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
EnumMapping(DiagnosticPosition pos, TypeSymbol forEnum) {
    this.forEnum = forEnum;
    this.values = new LinkedHashMap<>();
    this.pos = pos;
    Name varName = names
        .fromString(target.syntheticNameChar() +
                    "SwitchMap" +
                    target.syntheticNameChar() +
                    writer.xClassName(forEnum.type).toString()
                    .replace('/', '.')
                    .replace('.', target.syntheticNameChar()));
    ClassSymbol outerCacheClass = outerCacheClass();
    this.mapVar = new VarSymbol(STATIC | SYNTHETIC | FINAL,
                                varName,
                                new ArrayType(syms.intType, syms.arrayClass),
                                outerCacheClass);
    enterSynthetic(pos, mapVar, outerCacheClass.members());
}
 
Example #11
Source File: Printer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #12
Source File: Printer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #13
Source File: Printer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #14
Source File: Printer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #15
Source File: TypeMaker.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static String getTypeName(Type t, boolean full) {
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = ((ArrayType)t).elemtype;
        }
        s.insert(0, getTypeName(t, full));
        return s.toString();
    case CLASS:
        return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example #16
Source File: TypeMaker.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static String getTypeName(Type t, boolean full) {
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = ((ArrayType)t).elemtype;
        }
        s.insert(0, getTypeName(t, full));
        return s.toString();
    case CLASS:
        return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example #17
Source File: Printer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #18
Source File: TypeMaker.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static String getTypeName(Type t, boolean full) {
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = ((ArrayType)t).elemtype;
        }
        s.insert(0, getTypeName(t, full));
        return s.toString();
    case CLASS:
        return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example #19
Source File: Printer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Converts a set of method argument types into their corresponding
 * localized string representation.
 *
 * @param args arguments to be rendered
 * @param varArgs if true, the last method argument is regarded as a vararg
 * @param locale the locale in which the string is to be rendered
 * @return localized string representation
 */
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
    if (!varArgs) {
        return visitTypes(args, locale);
    } else {
        StringBuilder buf = new StringBuilder();
        while (args.tail.nonEmpty()) {
            buf.append(visit(args.head, locale));
            args = args.tail;
            buf.append(',');
        }
        if (args.head.hasTag(TypeTag.ARRAY)) {
            buf.append(visit(((ArrayType) args.head).elemtype, locale));
            if (args.head.getAnnotationMirrors().nonEmpty()) {
                buf.append(' ');
                buf.append(args.head.getAnnotationMirrors());
                buf.append(' ');
            }
            buf.append("...");
        } else {
            buf.append(visit(args.head, locale));
        }
        return buf.toString();
    }
}
 
Example #20
Source File: TypeMaker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static String getTypeName(Type t, boolean full) {
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = ((ArrayType)t).elemtype;
        }
        s.insert(0, getTypeName(t, full));
        return s.toString();
    case CLASS:
        return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example #21
Source File: TypeMaker.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static String getTypeName(Type t, boolean full) {
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = ((ArrayType)t).elemtype;
        }
        s.insert(0, getTypeName(t, full));
        return s.toString();
    case CLASS:
        return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example #22
Source File: Printer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void printBaseElementType(Type t, StringBuilder sb, Locale locale) {
    Type arrel = t;
    while (arrel.hasTag(TypeTag.ARRAY)) {
        arrel = arrel.unannotatedType();
        arrel = ((ArrayType) arrel).elemtype;
    }
    sb.append(visit(arrel, locale));
}
 
Example #23
Source File: Printer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void printBaseElementType(Type t, StringBuilder sb, Locale locale) {
    Type arrel = t;
    while (arrel.hasTag(TypeTag.ARRAY)) {
        arrel = ((ArrayType) arrel).elemtype;
    }
    sb.append(visit(arrel, locale));
}
 
Example #24
Source File: Printer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String visitArrayType(ArrayType t, Locale locale) {
    StringBuilder res = new StringBuilder();
    printBaseElementType(t, res, locale);
    printBrackets(t, res, locale);
    return res.toString();
}
 
Example #25
Source File: Printer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String visitArrayType(ArrayType t, Locale locale) {
    StringBuilder res = new StringBuilder();
    printBaseElementType(t, res, locale);
    printBrackets(t, res, locale);
    return res.toString();
}
 
Example #26
Source File: AnnotationProxyMaker.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void visitArray(Attribute.Array a) {
    Name elemName = ((ArrayType) a.type).elemtype.tsym.getQualifiedName();

    if (elemName.equals(elemName.table.names.java_lang_Class)) {   // Class[]
        // Construct a proxy for a MirroredTypesException
        ListBuffer<TypeMirror> elems = new ListBuffer<>();
        for (Attribute value : a.values) {
            Type elem = ((Attribute.Class) value).classType;
            elems.append(elem);
        }
        value = new MirroredTypesExceptionProxy(elems.toList());

    } else {
        int len = a.values.length;
        Class<?> returnClassSaved = returnClass;
        returnClass = returnClass.getComponentType();
        try {
            Object res = Array.newInstance(returnClass, len);
            for (int i = 0; i < len; i++) {
                a.values[i].accept(this);
                if (value == null || value instanceof ExceptionProxy) {
                    return;
                }
                try {
                    Array.set(res, i, value);
                } catch (IllegalArgumentException e) {
                    value = null;       // indicates a type mismatch
                    return;
                }
            }
            value = res;
        } finally {
            returnClass = returnClassSaved;
        }
    }
}
 
Example #27
Source File: JavacTrees.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Boolean visitArrayType(ArrayType t, Type s) {
    if (t == s)
        return true;

    if (s.isPartial())
        return visit(s, t);

    return s.hasTag(ARRAY)
        && visit(t.elemtype, types.elemtype(s));
}
 
Example #28
Source File: Printer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void printBrackets(Type t, StringBuilder sb, Locale locale) {
    Type arrel = t;
    while (arrel.hasTag(TypeTag.ARRAY)) {
        if (arrel.isAnnotated()) {
            sb.append(' ');
            sb.append(arrel.getAnnotationMirrors());
            sb.append(' ');
        }
        sb.append("[]");
        arrel = arrel.unannotatedType();
        arrel = ((ArrayType) arrel).elemtype;
    }
}
 
Example #29
Source File: Printer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void printBaseElementType(Type t, StringBuilder sb, Locale locale) {
    Type arrel = t;
    while (arrel.hasTag(TypeTag.ARRAY)) {
        arrel = arrel.unannotatedType();
        arrel = ((ArrayType) arrel).elemtype;
    }
    sb.append(visit(arrel, locale));
}
 
Example #30
Source File: JavacTrees.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Boolean visitArrayType(ArrayType t, Type s) {
    if (t == s)
        return true;

    if (s.isPartial())
        return visit(s, t);

    return s.hasTag(ARRAY)
        && visit(t.elemtype, types.elemtype(s));
}