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

The following examples show how to use com.sun.tools.javac.code.Attribute#Array . 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: AnnotationValueImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void visitArray(Attribute.Array a) {
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('{');

    boolean first = true;
    for (Attribute elem : a.values) {
        if (first) {
            first = false;
        } else {
            sb.append(", ");
        }
        elem.accept(this);
    }
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('}');
}
 
Example 2
Source File: AnnotationValueImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void visitArray(Attribute.Array a) {
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('{');

    boolean first = true;
    for (Attribute elem : a.values) {
        if (first) {
            first = false;
        } else {
            sb.append(", ");
        }
        elem.accept(this);
    }
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('}');
}
 
Example 3
Source File: AnnotationValueImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void visitArray(Attribute.Array a) {
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('{');

    boolean first = true;
    for (Attribute elem : a.values) {
        if (first) {
            first = false;
        } else {
            sb.append(", ");
        }
        elem.accept(this);
    }
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('}');
}
 
Example 4
Source File: AnnotationValueImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void visitArray(Attribute.Array a) {
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('{');

    boolean first = true;
    for (Attribute elem : a.values) {
        if (first) {
            first = false;
        } else {
            sb.append(", ");
        }
        elem.accept(this);
    }
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('}');
}
 
Example 5
Source File: AnnotationValueImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void visitArray(Attribute.Array a) {
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('{');

    boolean first = true;
    for (Attribute elem : a.values) {
        if (first) {
            first = false;
        } else {
            sb.append(", ");
        }
        elem.accept(this);
    }
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('}');
}
 
Example 6
Source File: AnnotationValueImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void visitArray(Attribute.Array a) {
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('{');

    boolean first = true;
    for (Attribute elem : a.values) {
        if (first) {
            first = false;
        } else {
            sb.append(", ");
        }
        elem.accept(this);
    }
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('}');
}
 
Example 7
Source File: AnnotationValueImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void visitArray(Attribute.Array a) {
    AnnotationValue vals[] = new AnnotationValue[a.values.length];
    for (int i = 0; i < vals.length; i++) {
        vals[i] = new AnnotationValueImpl(env, a.values[i]);
    }
    value = vals;
}
 
Example 8
Source File: AnnotationValueImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void visitArray(Attribute.Array a) {
    AnnotationValue vals[] = new AnnotationValue[a.values.length];
    for (int i = 0; i < vals.length; i++) {
        vals[i] = new AnnotationValueImpl(env, a.values[i]);
    }
    value = vals;
}
 
Example 9
Source File: AnnotationValueImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void visitArray(Attribute.Array a) {
    AnnotationValue vals[] = new AnnotationValue[a.values.length];
    for (int i = 0; i < vals.length; i++) {
        vals[i] = new AnnotationValueImpl(env, a.values[i]);
    }
    value = vals;
}
 
Example 10
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 11
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
Attribute.Array getAttributeTargetAttribute(TypeSymbol s) {
    Attribute.Compound atTarget = s.getAnnotationTypeMetadata().getTarget();
    if (atTarget == null) return null; // ok, is applicable
    Attribute atValue = atTarget.member(names.value);
    if (!(atValue instanceof Attribute.Array)) return null; // error recovery
    return (Attribute.Array) atValue;
}
 
Example 12
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 13
Source File: ClassReader.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void visitArrayAttributeProxy(ArrayAttributeProxy proxy) {
    int length = proxy.values.length();
    Attribute[] ats = new Attribute[length];
    Type elemtype = types.elemtype(type);
    int i = 0;
    for (List<Attribute> p = proxy.values; p.nonEmpty(); p = p.tail) {
        ats[i++] = deproxy(elemtype, p.head);
    }
    result = new Attribute.Array(type, ats);
}
 
Example 14
Source File: AnnotationValueImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void visitArray(Attribute.Array a) {
    AnnotationValue vals[] = new AnnotationValue[a.values.length];
    for (int i = 0; i < vals.length; i++) {
        vals[i] = new AnnotationValueImpl(env, a.values[i]);
    }
    value = vals;
}
 
Example 15
Source File: AnnotationValueImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void visitArray(Attribute.Array a) {
    AnnotationValue vals[] = new AnnotationValue[a.values.length];
    for (int i = 0; i < vals.length; i++) {
        vals[i] = new AnnotationValueImpl(env, a.values[i]);
    }
    value = vals;
}
 
Example 16
Source File: AnnotationValueImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void visitArray(Attribute.Array a) {
    AnnotationValue vals[] = new AnnotationValue[a.values.length];
    for (int i = 0; i < vals.length; i++) {
        vals[i] = new AnnotationValueImpl(env, a.values[i]);
    }
    value = vals;
}
 
Example 17
Source File: ClassReader.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void visitArray(Attribute.Array array) {
    throw new AssertionError(); // shouldn't happen
}
 
Example 18
Source File: DPrinter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void visitArray(Attribute.Array a) {
    printList("values", Arrays.asList(a.values));
    visitAttribute(a);
}
 
Example 19
Source File: DPrinter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void visitArray(Attribute.Array a) {
    printList("values", Arrays.asList(a.values));
    visitAttribute(a);
}
 
Example 20
Source File: DPrinter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void visitArray(Attribute.Array a) {
    printList("values", Arrays.asList(a.values));
    visitAttribute(a);
}