本文整理汇总了Java中com.sun.tools.classfile.Field类的典型用法代码示例。如果您正苦于以下问题:Java Field类的具体用法?Java Field怎么用?Java Field使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Field类属于com.sun.tools.classfile包,在下文中一共展示了Field类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFields
import com.sun.tools.classfile.Field; //导入依赖的package包/类
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");
}
示例2: getFieldName
import com.sun.tools.classfile.Field; //导入依赖的package包/类
String getFieldName(Field f) {
try {
return f.getName(constant_pool);
} catch (ConstantPoolException e) {
return report(e);
}
}
示例3: getKind
import com.sun.tools.classfile.Field; //导入依赖的package包/类
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");
}
}
示例4: testFields
import com.sun.tools.classfile.Field; //导入依赖的package包/类
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);
}
}
示例5: analyzeClassFile
import com.sun.tools.classfile.Field; //导入依赖的package包/类
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());
}
}
}
示例6: findAnnotations
import com.sun.tools.classfile.Field; //导入依赖的package包/类
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);
}
}
示例7: scanFields
import com.sun.tools.classfile.Field; //导入依赖的package包/类
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);
}
}