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
Source File: Annotate.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** 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 2
Source File: AnnotationProxyMaker.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 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 3
Source File: AnnotationProxyMaker.java    From javaide with GNU General Public License v3.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<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 4
Source File: AnnotationProxyMaker.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    value = new MirroredTypeExceptionProxy(c.type);
}
 
Example 5
Source File: DPrinter.java    From openjdk-8 with 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);
}
 
Example 6
Source File: AnnotationValueImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    value = TypeMaker.getType(env,
                              env.types.erasure(c.classType));
}
 
Example 7
Source File: AnnotationValueImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    sb.append(c);
}
 
Example 8
Source File: DPrinter.java    From openjdk-jdk9 with 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);
}
 
Example 9
Source File: ClassReader.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void visitClassAttributeProxy(ClassAttributeProxy proxy) {
    Type classType = resolvePossibleProxyType(proxy.classType);
    result = new Attribute.Class(types, classType);
}
 
Example 10
Source File: ClassWriter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void visitClass(Attribute.Class clazz) {
    databuf.appendByte('c');
    databuf.appendChar(pool.put(typeSig(types.erasure(clazz.classType))));
}
 
Example 11
Source File: AnnotationValueImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    value = TypeMaker.getType(env,
                              env.types.erasure(c.classType));
}
 
Example 12
Source File: AnnotationValueImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    sb.append(c);
}
 
Example 13
Source File: AnnotationValueImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    sb.append(c);
}
 
Example 14
Source File: DPrinter.java    From openjdk-8-source with 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);
}
 
Example 15
Source File: AnnotationProxyMaker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    value = new MirroredTypeExceptionProxy(c.type);
}
 
Example 16
Source File: AnnotationValueImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    value = TypeMaker.getType(env,
                              env.types.erasure(c.classType));
}
 
Example 17
Source File: AnnotationValueImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    sb.append(c);
}
 
Example 18
Source File: AnnotationValueImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    value = TypeMaker.getType(env,
                              env.types.erasure(c.classType));
}
 
Example 19
Source File: DPrinter.java    From TencentKona-8 with 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);
}
 
Example 20
Source File: AnnotationValueImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void visitClass(Attribute.Class c) {
    sb.append(c);
}