Java 类com.sun.tools.classfile.Field 实例源码

项目:openjdk-jdk10    文件:Driver.java   
private void testFields(Map<String, ExpectedSignature> expectedSignatures, ClassFile classFile)
        throws ConstantPoolException {
    String className = classFile.getName();
    Set<String> foundFields = new HashSet<>();
    for (Field field : classFile.fields) {
        String fieldName = field.getName(classFile.constant_pool);
        printf("Testing field %s\n", fieldName);
        testAttribute(
                fieldName,
                classFile,
                () -> (Signature_attribute) field.attributes.get(Attribute.Signature),
                expectedSignatures.get(fieldName));
        foundFields.add(fieldName);
    }
    checkAllMembersFound(foundFields, expectedSignatures,
            "Checking that all fields of class " + className + " with Signature attribute found");
}
项目:openjdk9    文件:Driver.java   
private void testFields(Map<String, ExpectedSignature> expectedSignatures, ClassFile classFile)
        throws ConstantPoolException {
    String className = classFile.getName();
    Set<String> foundFields = new HashSet<>();
    for (Field field : classFile.fields) {
        String fieldName = field.getName(classFile.constant_pool);
        printf("Testing field %s\n", fieldName);
        testAttribute(
                fieldName,
                classFile,
                () -> (Signature_attribute) field.attributes.get(Attribute.Signature),
                expectedSignatures.get(fieldName));
        foundFields.add(fieldName);
    }
    checkAllMembersFound(foundFields, expectedSignatures,
            "Checking that all fields of class " + className + " with Signature attribute found");
}
项目:OpenJSharp    文件:ClassWriter.java   
String getFieldName(Field f) {
    try {
        return f.getName(constant_pool);
    } catch (ConstantPoolException e) {
        return report(e);
    }
}
项目:jdk8u-jdk    文件:ClassReader.java   
private AccessFlags.Kind getKind(Element e) {
    switch(e.getName()) {
        case "Class":
            return AccessFlags.Kind.Class;
        case "InnerClass":
            return AccessFlags.Kind.InnerClass;
        case "Field":
            return AccessFlags.Kind.Field ;
        case "Method":
            return AccessFlags.Kind.Method;
        default: throw new RuntimeException("should not reach here");
    }
}
项目:openjdk-jdk10    文件:ClassWriter.java   
String getFieldName(Field f) {
    try {
        return f.getName(constant_pool);
    } catch (ConstantPoolException e) {
        return report(e);
    }
}
项目:openjdk-jdk10    文件:DeprecatedTest.java   
private void testFields(ClassFile cf) throws ConstantPoolException {
    for (Field f : cf.fields) {
        String fieldName = cf.constant_pool.getUTF8Value(f.name_index);
        echo("Testing field : " + fieldName);
        Deprecated_attribute attr = (Deprecated_attribute)
                f.attributes.get(Attribute.Deprecated);
        testAttribute(fieldName, attr, cf);
    }
}
项目:openjdk-jdk10    文件:DetectMutableStaticFields.java   
void analyzeClassFile(ClassFile classFileToCheck)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    boolean enumClass =
            (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
    boolean nonFinalStaticEnumField;
    boolean nonFinalStaticField;

    currentFieldsToIgnore =
            classFieldsToIgnoreMap.get(classFileToCheck.getName());

    for (Field field : classFileToCheck.fields) {
        if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
            continue;
        }
        nonFinalStaticEnumField =
                (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
        nonFinalStaticField =
                (field.access_flags.flags & ACC_STATIC) != 0 &&
                (field.access_flags.flags & ACC_FINAL) == 0;
        if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
            errors.add("There is a mutable field named " +
                    field.getName(classFileToCheck.constant_pool) +
                    ", at class " +
                    classFileToCheck.getName());
        }
    }
}
项目:openjdk-jdk10    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, List<TypeAnnotation> annos) {
    findAnnotations(cf, Attribute.RuntimeVisibleTypeAnnotations, annos);
    findAnnotations(cf, Attribute.RuntimeInvisibleTypeAnnotations, annos);

    for (Field f : cf.fields) {
        findAnnotations(cf, f, annos);
    }
    for (Method m: cf.methods) {
        findAnnotations(cf, m, annos);
    }
}
项目:openjdk-jdk10    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, Field m, String name, List<TypeAnnotation> annos) {
    int index = m.attributes.getIndex(cf.constant_pool, name);
    if (index != -1) {
        Attribute attr = m.attributes.get(index);
        assert attr instanceof RuntimeTypeAnnotations_attribute;
        RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
        annos.addAll(Arrays.asList(tAttr.annotations));
    }
}
项目:openjdk-jdk10    文件:StringSharingPlugin.java   
private void scanFields(Set<Integer> utf8Descriptors)
        throws Exception {
    for (Field field : cf.fields) {
        int descriptorIndex = field.descriptor.index;
        utf8Descriptors.add(descriptorIndex);
        scanAttributes(field.attributes, utf8Descriptors);
    }

}
项目:openjdk-jdk10    文件:ClassReader.java   
private AccessFlags.Kind getKind(Element e) {
    switch(e.getName()) {
        case "Class":
            return AccessFlags.Kind.Class;
        case "InnerClass":
            return AccessFlags.Kind.InnerClass;
        case "Field":
            return AccessFlags.Kind.Field ;
        case "Method":
            return AccessFlags.Kind.Method;
        default: throw new RuntimeException("should not reach here");
    }
}
项目:openjdk9    文件:ClassWriter.java   
String getFieldName(Field f) {
    try {
        return f.getName(constant_pool);
    } catch (ConstantPoolException e) {
        return report(e);
    }
}
项目:openjdk9    文件:DeprecatedTest.java   
private void testFields(ClassFile cf) throws ConstantPoolException {
    for (Field f : cf.fields) {
        String fieldName = cf.constant_pool.getUTF8Value(f.name_index);
        echo("Testing field : " + fieldName);
        Deprecated_attribute attr = (Deprecated_attribute)
                f.attributes.get(Attribute.Deprecated);
        testAttribute(fieldName, attr, cf);
    }
}
项目:openjdk9    文件:DetectMutableStaticFields.java   
void analyzeClassFile(ClassFile classFileToCheck)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    boolean enumClass =
            (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
    boolean nonFinalStaticEnumField;
    boolean nonFinalStaticField;

    currentFieldsToIgnore =
            classFieldsToIgnoreMap.get(classFileToCheck.getName());

    for (Field field : classFileToCheck.fields) {
        if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
            continue;
        }
        nonFinalStaticEnumField =
                (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
        nonFinalStaticField =
                (field.access_flags.flags & ACC_STATIC) != 0 &&
                (field.access_flags.flags & ACC_FINAL) == 0;
        if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
            errors.add("There is a mutable field named " +
                    field.getName(classFileToCheck.constant_pool) +
                    ", at class " +
                    classFileToCheck.getName());
        }
    }
}
项目:openjdk9    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, List<TypeAnnotation> annos) {
    findAnnotations(cf, Attribute.RuntimeVisibleTypeAnnotations, annos);
    findAnnotations(cf, Attribute.RuntimeInvisibleTypeAnnotations, annos);

    for (Field f : cf.fields) {
        findAnnotations(cf, f, annos);
    }
    for (Method m: cf.methods) {
        findAnnotations(cf, m, annos);
    }
}
项目:openjdk9    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, Field m, String name, List<TypeAnnotation> annos) {
    int index = m.attributes.getIndex(cf.constant_pool, name);
    if (index != -1) {
        Attribute attr = m.attributes.get(index);
        assert attr instanceof RuntimeTypeAnnotations_attribute;
        RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
        annos.addAll(Arrays.asList(tAttr.annotations));
    }
}
项目:openjdk9    文件:StringSharingPlugin.java   
private void scanFields(Set<Integer> utf8Descriptors)
        throws Exception {
    for (Field field : cf.fields) {
        int descriptorIndex = field.descriptor.index;
        utf8Descriptors.add(descriptorIndex);
        scanAttributes(field.attributes, utf8Descriptors);
    }

}
项目:openjdk9    文件:ClassReader.java   
private AccessFlags.Kind getKind(Element e) {
    switch(e.getName()) {
        case "Class":
            return AccessFlags.Kind.Class;
        case "InnerClass":
            return AccessFlags.Kind.InnerClass;
        case "Field":
            return AccessFlags.Kind.Field ;
        case "Method":
            return AccessFlags.Kind.Method;
        default: throw new RuntimeException("should not reach here");
    }
}
项目:jdk8u_jdk    文件:ClassReader.java   
private AccessFlags.Kind getKind(Element e) {
    switch(e.getName()) {
        case "Class":
            return AccessFlags.Kind.Class;
        case "InnerClass":
            return AccessFlags.Kind.InnerClass;
        case "Field":
            return AccessFlags.Kind.Field ;
        case "Method":
            return AccessFlags.Kind.Method;
        default: throw new RuntimeException("should not reach here");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ClassWriter.java   
String getFieldName(Field f) {
    try {
        return f.getName(constant_pool);
    } catch (ConstantPoolException e) {
        return report(e);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DetectMutableStaticFields.java   
void analyzeClassFile(ClassFile classFileToCheck)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    boolean enumClass =
            (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
    boolean nonFinalStaticEnumField;
    boolean nonFinalStaticField;

    currentFieldsToIgnore =
            classFieldsToIgnoreMap.get(classFileToCheck.getName());

    for (Field field : classFileToCheck.fields) {
        if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
            continue;
        }
        nonFinalStaticEnumField =
                (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
        nonFinalStaticField =
                (field.access_flags.flags & ACC_STATIC) != 0 &&
                (field.access_flags.flags & ACC_FINAL) == 0;
        if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
            errors.add("There is a mutable field named " +
                    field.getName(classFileToCheck.constant_pool) +
                    ", at class " +
                    classFileToCheck.getName());
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, List<TypeAnnotation> annos) {
    findAnnotations(cf, Attribute.RuntimeVisibleTypeAnnotations, annos);
    findAnnotations(cf, Attribute.RuntimeInvisibleTypeAnnotations, annos);

    for (Field f : cf.fields) {
        findAnnotations(cf, f, annos);
    }
    for (Method m: cf.methods) {
        findAnnotations(cf, m, annos);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, Field m, String name, List<TypeAnnotation> annos) {
    int index = m.attributes.getIndex(cf.constant_pool, name);
    if (index != -1) {
        Attribute attr = m.attributes.get(index);
        assert attr instanceof RuntimeTypeAnnotations_attribute;
        RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
        annos.addAll(Arrays.asList(tAttr.annotations));
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ClassReader.java   
private AccessFlags.Kind getKind(Element e) {
    switch(e.getName()) {
        case "Class":
            return AccessFlags.Kind.Class;
        case "InnerClass":
            return AccessFlags.Kind.InnerClass;
        case "Field":
            return AccessFlags.Kind.Field ;
        case "Method":
            return AccessFlags.Kind.Method;
        default: throw new RuntimeException("should not reach here");
    }
}
项目:jsr308-langtools    文件:ClassWriter.java   
String getFieldName(Field f) {
    try {
        return f.getName(constant_pool);
    } catch (ConstantPoolException e) {
        return report(e);
    }
}
项目:jsr308-langtools    文件:DetectMutableStaticFields.java   
void analyzeClassFile(ClassFile classFileToCheck)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    boolean enumClass =
            (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
    boolean nonFinalStaticEnumField;
    boolean nonFinalStaticField;

    currentFieldsToIgnore =
            classFieldsToIgnoreMap.get(classFileToCheck.getName());

    for (Field field : classFileToCheck.fields) {
        if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
            continue;
        }
        nonFinalStaticEnumField =
                (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
        nonFinalStaticField =
                (field.access_flags.flags & ACC_STATIC) != 0 &&
                (field.access_flags.flags & ACC_FINAL) == 0;
        if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
            errors.add("There is a mutable field named " +
                    field.getName(classFileToCheck.constant_pool) +
                    ", at class " +
                    classFileToCheck.getName());
        }
    }
}
项目:jsr308-langtools    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, List<TypeAnnotation> annos) {
    findAnnotations(cf, Attribute.RuntimeVisibleTypeAnnotations, annos);
    findAnnotations(cf, Attribute.RuntimeInvisibleTypeAnnotations, annos);

    for (Field f : cf.fields) {
        findAnnotations(cf, f, annos);
    }
    for (Method m: cf.methods) {
        findAnnotations(cf, m, annos);
    }
}
项目:jsr308-langtools    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, Field m, String name, List<TypeAnnotation> annos) {
    int index = m.attributes.getIndex(cf.constant_pool, name);
    if (index != -1) {
        Attribute attr = m.attributes.get(index);
        assert attr instanceof RuntimeTypeAnnotations_attribute;
        RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
        annos.addAll(Arrays.asList(tAttr.annotations));
    }
}
项目:infobip-open-jdk-8    文件:ClassWriter.java   
String getFieldName(Field f) {
    try {
        return f.getName(constant_pool);
    } catch (ConstantPoolException e) {
        return report(e);
    }
}
项目:infobip-open-jdk-8    文件:DetectMutableStaticFields.java   
void analyzeClassFile(ClassFile classFileToCheck)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    boolean enumClass =
            (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
    boolean nonFinalStaticEnumField;
    boolean nonFinalStaticField;

    currentFieldsToIgnore =
            classFieldsToIgnoreMap.get(classFileToCheck.getName());

    for (Field field : classFileToCheck.fields) {
        if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
            continue;
        }
        nonFinalStaticEnumField =
                (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
        nonFinalStaticField =
                (field.access_flags.flags & ACC_STATIC) != 0 &&
                (field.access_flags.flags & ACC_FINAL) == 0;
        if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
            errors.add("There is a mutable field named " +
                    field.getName(classFileToCheck.constant_pool) +
                    ", at class " +
                    classFileToCheck.getName());
        }
    }
}
项目:infobip-open-jdk-8    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, List<TypeAnnotation> annos) {
    findAnnotations(cf, Attribute.RuntimeVisibleTypeAnnotations, annos);
    findAnnotations(cf, Attribute.RuntimeInvisibleTypeAnnotations, annos);

    for (Field f : cf.fields) {
        findAnnotations(cf, f, annos);
    }
    for (Method m: cf.methods) {
        findAnnotations(cf, m, annos);
    }
}
项目:infobip-open-jdk-8    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, Field m, String name, List<TypeAnnotation> annos) {
    int index = m.attributes.getIndex(cf.constant_pool, name);
    if (index != -1) {
        Attribute attr = m.attributes.get(index);
        assert attr instanceof RuntimeTypeAnnotations_attribute;
        RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
        annos.addAll(Arrays.asList(tAttr.annotations));
    }
}
项目:infobip-open-jdk-8    文件:ClassReader.java   
private AccessFlags.Kind getKind(Element e) {
    switch(e.getName()) {
        case "Class":
            return AccessFlags.Kind.Class;
        case "InnerClass":
            return AccessFlags.Kind.InnerClass;
        case "Field":
            return AccessFlags.Kind.Field ;
        case "Method":
            return AccessFlags.Kind.Method;
        default: throw new RuntimeException("should not reach here");
    }
}
项目:jdk8u-dev-jdk    文件:ClassReader.java   
private AccessFlags.Kind getKind(Element e) {
    switch(e.getName()) {
        case "Class":
            return AccessFlags.Kind.Class;
        case "InnerClass":
            return AccessFlags.Kind.InnerClass;
        case "Field":
            return AccessFlags.Kind.Field ;
        case "Method":
            return AccessFlags.Kind.Method;
        default: throw new RuntimeException("should not reach here");
    }
}
项目:openjdk-source-code-learn    文件:ClassWriter.java   
String getFieldName(Field f) {
    try {
        return f.getName(constant_pool);
    } catch (ConstantPoolException e) {
        return report(e);
    }
}
项目:OLD-OpenJDK8    文件:ClassWriter.java   
String getFieldName(Field f) {
    try {
        return f.getName(constant_pool);
    } catch (ConstantPoolException e) {
        return report(e);
    }
}
项目:OLD-OpenJDK8    文件:DetectMutableStaticFields.java   
void analyzeClassFile(ClassFile classFileToCheck)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    boolean enumClass =
            (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
    boolean nonFinalStaticEnumField;
    boolean nonFinalStaticField;

    currentFieldsToIgnore =
            classFieldsToIgnoreMap.get(classFileToCheck.getName());

    for (Field field : classFileToCheck.fields) {
        if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
            continue;
        }
        nonFinalStaticEnumField =
                (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
        nonFinalStaticField =
                (field.access_flags.flags & ACC_STATIC) != 0 &&
                (field.access_flags.flags & ACC_FINAL) == 0;
        if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
            errors.add("There is a mutable field named " +
                    field.getName(classFileToCheck.constant_pool) +
                    ", at class " +
                    classFileToCheck.getName());
        }
    }
}
项目:OLD-OpenJDK8    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, List<TypeAnnotation> annos) {
    findAnnotations(cf, Attribute.RuntimeVisibleTypeAnnotations, annos);
    findAnnotations(cf, Attribute.RuntimeInvisibleTypeAnnotations, annos);

    for (Field f : cf.fields) {
        findAnnotations(cf, f, annos);
    }
    for (Method m: cf.methods) {
        findAnnotations(cf, m, annos);
    }
}
项目:OLD-OpenJDK8    文件:ReferenceInfoUtil.java   
private static void findAnnotations(ClassFile cf, Field m, String name, List<TypeAnnotation> annos) {
    int index = m.attributes.getIndex(cf.constant_pool, name);
    if (index != -1) {
        Attribute attr = m.attributes.get(index);
        assert attr instanceof RuntimeTypeAnnotations_attribute;
        RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
        annos.addAll(Arrays.asList(tAttr.annotations));
    }
}
项目:OLD-OpenJDK8    文件:ClassReader.java   
private AccessFlags.Kind getKind(Element e) {
    switch(e.getName()) {
        case "Class":
            return AccessFlags.Kind.Class;
        case "InnerClass":
            return AccessFlags.Kind.InnerClass;
        case "Field":
            return AccessFlags.Kind.Field ;
        case "Method":
            return AccessFlags.Kind.Method;
        default: throw new RuntimeException("should not reach here");
    }
}