Java Code Examples for com.sun.tools.javac.code.Attribute#Class

The following examples show how to use com.sun.tools.javac.code.Attribute#Class . 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
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<TypeMirror>();
        for (Attribute value : a.values) {
            Type elem = ((Attribute.Class) value).type;
            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 2
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 3
/** Extract the actual Type to be used for a containing annotation. */
private Type extractContainingType(Attribute.Compound ca,
                                   DiagnosticPosition pos,
                                   TypeSymbol annoDecl)
{
    // The next three checks check that the Repeatable annotation
    // on the declaration of the annotation type that is repeating is
    // valid.

    // Repeatable must have at least one element
    if (ca.values.isEmpty()) {
        log.error(pos, Errors.InvalidRepeatableAnnotation(annoDecl));
        return null;
    }
    Pair<MethodSymbol,Attribute> p = ca.values.head;
    Name name = p.fst.name;
    if (name != names.value) { // should contain only one element, named "value"
        log.error(pos, Errors.InvalidRepeatableAnnotation(annoDecl));
        return null;
    }
    if (!(p.snd instanceof Attribute.Class)) { // check that the value of "value" is an Attribute.Class
        log.error(pos, Errors.InvalidRepeatableAnnotation(annoDecl));
        return null;
    }

    return ((Attribute.Class)p.snd).getValue();
}
 
Example 4
public void visitClass(Attribute.Class c) {
    value = TypeMaker.getType(env,
                              env.types.erasure(c.classType));
}
 
Example 5
public void visitClass(Attribute.Class c) {
    sb.append(c);
}
 
Example 6
public void visitClass(Attribute.Class a) {
    printObject("classType", a.classType, Details.SUMMARY);
    visitAttribute(a);
}
 
Example 7
public void visitClass(Attribute.Class c) {
    value = TypeMaker.getType(env,
                              env.types.erasure(c.classType));
}
 
Example 8
public void visitClass(Attribute.Class c) {
    sb.append(c);
}
 
Example 9
public void visitClass(Attribute.Class c) {
    value = TypeMaker.getType(env,
                              env.types.erasure(c.classType));
}
 
Example 10
public void visitClass(Attribute.Class c) {
    value = new MirroredTypeExceptionProxy(c.type);
}
 
Example 11
public void visitClass(Attribute.Class a) {
    printObject("classType", a.classType, Details.SUMMARY);
    visitAttribute(a);
}
 
Example 12
public void visitClass(Attribute.Class c) {
    sb.append(c);
}
 
Example 13
public void visitClass(Attribute.Class c) {
    sb.append(c);
}
 
Example 14
public void visitClass(Attribute.Class c) {
    value = new MirroredTypeExceptionProxy(c.type);
}
 
Example 15
public void visitClass(Attribute.Class clazz) {
    databuf.appendByte('c');
    databuf.appendChar(pool.put(typeSig(types.erasure(clazz.classType))));
}
 
Example 16
@Override
public void visitClassAttributeProxy(ClassAttributeProxy proxy) {
    Type classType = resolvePossibleProxyType(proxy.classType);
    result = new Attribute.Class(types, classType);
}
 
Example 17
public void visitClass(Attribute.Class a) {
    printObject("classType", a.classType, Details.SUMMARY);
    visitAttribute(a);
}
 
Example 18
public void visitClass(Attribute.Class c) {
    sb.append(c);
}
 
Example 19
public void visitClass(Attribute.Class c) {
    value = TypeMaker.getType(env,
                              env.types.erasure(c.classType));
}
 
Example 20
Source Project: openjdk-8   File: DPrinter.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void visitClass(Attribute.Class a) {
    printObject("classType", a.classType, Details.SUMMARY);
    visitAttribute(a);
}