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

The following examples show how to use com.sun.tools.javac.code.Attribute#Enum . 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
@SuppressWarnings({"unchecked", "rawtypes"})
public void visitEnum(Attribute.Enum e) {
    if (returnClass.isEnum()) {
        String constName = e.value.toString();
        try {
            value = Enum.valueOf((Class)returnClass, constName);
        } catch (IllegalArgumentException ex) {
            value = new EnumConstantNotPresentExceptionProxy(
                                (Class<Enum<?>>) returnClass, constName);
        }
    } else {
        value = null;   // indicates a type mismatch
    }
}
 
Example 2
@SuppressWarnings({"unchecked", "rawtypes"})
public void visitEnum(Attribute.Enum e) {
    if (returnClass.isEnum()) {
        String constName = e.value.toString();
        try {
            value = Enum.valueOf((Class)returnClass, constName);
        } catch (IllegalArgumentException ex) {
            value = new EnumConstantNotPresentExceptionProxy(
                                (Class<Enum<?>>) returnClass, constName);
        }
    } else {
        value = null;   // indicates a type mismatch
    }
}
 
Example 3
private Attribute getAnnotationEnumValue(Type expectedElementType, JCExpression tree, Env<AttrContext> env) {
    Type result = attr.attribTree(tree, env, annotationValueInfo(expectedElementType));
    Symbol sym = TreeInfo.symbol(tree);
    if (sym == null ||
            TreeInfo.nonstaticSelect(tree) ||
            sym.kind != VAR ||
            (sym.flags() & Flags.ENUM) == 0) {
        log.error(tree.pos(), Errors.EnumAnnotationMustBeEnumConstant);
        return new Attribute.Error(result.getOriginalType());
    }
    VarSymbol enumerator = (VarSymbol) sym;
    return new Attribute.Enum(expectedElementType, enumerator);
}
 
Example 4
@SuppressWarnings({"unchecked", "rawtypes"})
public void visitEnum(Attribute.Enum e) {
    if (returnClass.isEnum()) {
        String constName = e.value.toString();
        try {
            value = Enum.valueOf((Class)returnClass, constName);
        } catch (IllegalArgumentException ex) {
            value = new EnumConstantNotPresentExceptionProxy(
                                (Class<Enum<?>>) returnClass, constName);
        }
    } else {
        value = null;   // indicates a type mismatch
    }
}
 
Example 5
public void visitEnum(Attribute.Enum e) {
    value = env.getFieldDoc(e.value);
}
 
Example 6
public void visitEnum(Attribute.Enum e) {
    value = env.getFieldDoc(e.value);
}
 
Example 7
public void visitEnum(Attribute.Enum a) {
    printSymbol("value", a.value, Details.SUMMARY);
    visitAttribute(a);
}
 
Example 8
public void visitEnum(Attribute.Enum e) {
    value = env.getFieldDoc(e.value);
}
 
Example 9
public void visitEnum(Attribute.Enum e) {
    sb.append(e);
}
 
Example 10
Source Project: jdk8u60   File: DPrinter.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void visitEnum(Attribute.Enum a) {
    printSymbol("value", a.value, Details.SUMMARY);
    visitAttribute(a);
}
 
Example 11
public void visitEnum(Attribute.Enum e) {
    value = env.getFieldDoc(e.value);
}
 
Example 12
public void visitEnum(Attribute.Enum e) {
    sb.append(e);
}
 
Example 13
public void visitEnum(Attribute.Enum a) {
    printSymbol("value", a.value, Details.SUMMARY);
    visitAttribute(a);
}
 
Example 14
public void visitEnum(Attribute.Enum e) {
    databuf.appendByte('e');
    databuf.appendChar(pool.put(typeSig(e.value.type)));
    databuf.appendChar(pool.put(e.value.name));
}
 
Example 15
public void visitEnum(Attribute.Enum e) {
    throw new AssertionError(); // shouldn't happen
}
 
Example 16
public void visitEnum(Attribute.Enum e) {
    value = env.getFieldDoc(e.value);
}
 
Example 17
/** Is the annotation applicable to the symbol? */
boolean annotationApplicable(JCAnnotation a, Symbol s) {
    Attribute.Array arr = getAttributeTargetAttribute(a.annotationType.type.tsym);
    Name[] targets;

    if (arr == null) {
        targets = defaultTargetMetaInfo(a, s);
    } else {
        // TODO: can we optimize this?
        targets = new Name[arr.values.length];
        for (int i=0; i<arr.values.length; ++i) {
            Attribute app = arr.values[i];
            if (!(app instanceof Attribute.Enum)) {
                return true; // recovery
            }
            Attribute.Enum e = (Attribute.Enum) app;
            targets[i] = e.value.name;
        }
    }
    for (Name target : targets) {
        if (target == names.TYPE) {
            if (s.kind == TYP)
                return true;
        } else if (target == names.FIELD) {
            if (s.kind == VAR && s.owner.kind != MTH)
                return true;
        } else if (target == names.METHOD) {
            if (s.kind == MTH && !s.isConstructor())
                return true;
        } else if (target == names.PARAMETER) {
            if (s.kind == VAR && s.owner.kind == MTH &&
                  (s.flags() & PARAMETER) != 0) {
                return true;
            }
        } else if (target == names.CONSTRUCTOR) {
            if (s.kind == MTH && s.isConstructor())
                return true;
        } else if (target == names.LOCAL_VARIABLE) {
            if (s.kind == VAR && s.owner.kind == MTH &&
                  (s.flags() & PARAMETER) == 0) {
                return true;
            }
        } else if (target == names.ANNOTATION_TYPE) {
            if (s.kind == TYP && (s.flags() & ANNOTATION) != 0) {
                return true;
            }
        } else if (target == names.PACKAGE) {
            if (s.kind == PCK)
                return true;
        } else if (target == names.TYPE_USE) {
            if (s.kind == VAR && s.owner.kind == MTH && s.type.hasTag(NONE)) {
                //cannot type annotate implictly typed locals
                return false;
            } else if (s.kind == TYP || s.kind == VAR ||
                    (s.kind == MTH && !s.isConstructor() &&
                            !s.type.getReturnType().hasTag(VOID)) ||
                    (s.kind == MTH && s.isConstructor())) {
                return true;
            }
        } else if (target == names.TYPE_PARAMETER) {
            if (s.kind == TYP && s.type.hasTag(TYPEVAR))
                return true;
        } else
            return true; // Unknown ElementType. This should be an error at declaration site,
                         // assume applicable.
    }
    return false;
}
 
Example 18
public void visitEnum(Attribute.Enum e) {
    value = env.getFieldDoc(e.value);
}
 
Example 19
public void visitEnum(Attribute.Enum a) {
    printSymbol("value", a.value, Details.SUMMARY);
    visitAttribute(a);
}
 
Example 20
public void visitEnum(Attribute.Enum a) {
    printSymbol("value", a.value, Details.SUMMARY);
    visitAttribute(a);
}