当前位置: 首页>>代码示例>>Java>>正文


Java FieldInfo类代码示例

本文整理汇总了Java中javassist.bytecode.FieldInfo的典型用法代码示例。如果您正苦于以下问题:Java FieldInfo类的具体用法?Java FieldInfo怎么用?Java FieldInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FieldInfo类属于javassist.bytecode包,在下文中一共展示了FieldInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClassFields

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
public List<FieldInfo> getClassFields(String classname, ConstPool cp) {
	ClassPathList list = pathList;
    List<FieldInfo> fields = null;
    while (list != null) {
    	if (!(list.path instanceof DalvikClassPath)) {
    		list = list.next;
    		continue;
    	}
    	
        fields = ((DalvikClassPath)list.path).getClassFields(classname, cp);
        
        if (fields == null)
            list = list.next;
        else
            return fields;
    }

    return null;    // not found
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:20,代码来源:ClassPoolTail.java

示例2: scan

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
@Override
public void scan(final Object cls) {
  final ClassFile classFile = (ClassFile)cls;
  AnnotationsAttribute annotations = ((AnnotationsAttribute)classFile.getAttribute(AnnotationsAttribute.visibleTag));
  if (annotations != null) {
    boolean isAnnotated = false;
    for (javassist.bytecode.annotation.Annotation a : annotations.getAnnotations()) {
      if (annotationsToScan.contains(a.getTypeName())) {
        isAnnotated = true;
      }
    }
    if (isAnnotated) {
      List<AnnotationDescriptor> classAnnotations = getAnnotationDescriptors(annotations);
      @SuppressWarnings("unchecked")
      List<FieldInfo> classFields = classFile.getFields();
      List<FieldDescriptor> fieldDescriptors = new ArrayList<>(classFields.size());
      for (FieldInfo field : classFields) {
        String fieldName = field.getName();
        AnnotationsAttribute fieldAnnotations = ((AnnotationsAttribute)field.getAttribute(AnnotationsAttribute.visibleTag));
        fieldDescriptors.add(new FieldDescriptor(fieldName, field.getDescriptor(), getAnnotationDescriptors(fieldAnnotations)));
      }
      functions.add(new AnnotatedClassDescriptor(classFile.getName(), classAnnotations, fieldDescriptors));
    }
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:26,代码来源:ClassPathScanner.java

示例3: addReadWriteMethods

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
private void addReadWriteMethods(ClassFile classfile)
		throws CannotCompileException {
	List fields = classfile.getFields();
	for (Iterator field_iter = fields.iterator(); field_iter.hasNext();) {
		FieldInfo finfo = (FieldInfo) field_iter.next();
		if ((finfo.getAccessFlags() & AccessFlag.STATIC) == 0
		    && (!finfo.getName().equals(HANDLER_FIELD_NAME))) {
			// case of non-static field
			if (filter.handleRead(finfo.getDescriptor(), finfo
					.getName())) {
				addReadMethod(classfile, finfo);
				readableFields.put(finfo.getName(), finfo
						.getDescriptor());
			}
			if (filter.handleWrite(finfo.getDescriptor(), finfo
					.getName())) {
				addWriteMethod(classfile, finfo);
				writableFields.put(finfo.getName(), finfo
						.getDescriptor());
			}
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:24,代码来源:FieldTransformer.java

示例4: getDeclaredFields

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
private ArrayList<Signature> getDeclaredFields(boolean areStatic) {
    if ((areStatic ? this.fieldsStatic : this.fieldsObject) == null) {
        final ArrayList<Signature> fields = new ArrayList<Signature>();
        @SuppressWarnings("unchecked")
        final List<FieldInfo> fieldsJA = this.cf.getFields();
        for (FieldInfo fld : fieldsJA) {
            if (Modifier.isStatic(AccessFlag.toModifier(fld.getAccessFlags())) == areStatic) {
                final Signature sig = new Signature(getClassName(), fld.getDescriptor(), fld.getName());
                fields.add(sig);
            }
        }
        if (areStatic) {
            this.fieldsStatic = fields;
        } else {
            this.fieldsObject = fields;
        }
    }
    return (areStatic ? this.fieldsStatic : this.fieldsObject);
}
 
开发者ID:pietrobraione,项目名称:jbse,代码行数:20,代码来源:ClassFileJavassist.java

示例5: getFields

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
public List<JField> getFields() {

    	boolean isJavaLangThrowable = "java.lang.Throwable".equals(this.getName());
    	boolean isJavaLangSystem = "java.lang.System".equals(this.getName());
    	
        final List<JField> retVal = new ArrayList<JField>();
        @SuppressWarnings("unchecked")
        final List<FieldInfo> fields = (List<FieldInfo>) getClassFile().getFields();

        for (FieldInfo next : fields) {
        	if (isJavaLangThrowable && ("backtrace".equals(next.getName()))) {
        		// See http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=d7621f5189c86f127fe5737490903?bug_id=4496456
        		continue;
        	}
        	if (isJavaLangSystem && ("security".equals(next.getName()))) {
                continue;
            }
            retVal.add(JField.getJField(next, this, getResolver()));
        }
        return retVal;
    }
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:22,代码来源:JClass.java

示例6: isConfigPropertyAnnotationPresent

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
private static boolean isConfigPropertyAnnotationPresent(ClassFile cf, Log log) {

        AttributeInfo classAttribute = cf.getAttribute(AnnotationsAttribute.visibleTag);
        if (classAttribute != null) {
            if (findAnnotation(cf, log, classAttribute, "com.avast.syringe.config.ConfigBean")) {
                return true;
            }
        }

        List<FieldInfo> fields = cf.getFields();
        for (FieldInfo field : fields) {
            AttributeInfo fieldAttribute = field.getAttribute(AnnotationsAttribute.visibleTag);
            if (fieldAttribute != null) {
                if (findAnnotation(cf, log, fieldAttribute, "com.avast.syringe.config.ConfigProperty")) {
                    return true;
                }
            }
        }
        return false;
    }
 
开发者ID:avast,项目名称:syringe-maven-plugin,代码行数:21,代码来源:ModuleScannerMojo.java

示例7: addReadWriteMethods

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
private void addReadWriteMethods(ClassFile classfile) throws CannotCompileException, BadBytecode {
	final List fields = classfile.getFields();
	for ( Object field : fields ) {
		final FieldInfo finfo = (FieldInfo) field;
		if ( (finfo.getAccessFlags() & AccessFlag.STATIC) == 0 && (!finfo.getName().equals( HANDLER_FIELD_NAME )) ) {
			// case of non-static field
			if ( filter.handleRead( finfo.getDescriptor(), finfo.getName() ) ) {
				addReadMethod( classfile, finfo );
			}
			if ( filter.handleWrite( finfo.getDescriptor(), finfo.getName() ) ) {
				addWriteMethod( classfile, finfo );
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:FieldTransformer.java

示例8: scan

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
@Override
public void scan(final Object cls) {
  final ClassFile classFile = (ClassFile)cls;
  AnnotationsAttribute annotations = ((AnnotationsAttribute)classFile.getAttribute(AnnotationsAttribute.visibleTag));
  if (annotations != null) {
    boolean isAnnotated = false;
    for (javassist.bytecode.annotation.Annotation a : annotations.getAnnotations()) {
      if (annotationsToScan.contains(a.getTypeName())) {
        isAnnotated = true;
      }
    }
    if (isAnnotated) {
      List<AnnotationDescriptor> classAnnotations = getAnnotationDescriptors(annotations);
      @SuppressWarnings("unchecked")
      List<FieldInfo> classFields = classFile.getFields();
      List<FieldDescriptor> fieldDescriptors = new ArrayList<>(classFields.size());
      for (FieldInfo field : classFields) {
        String fieldName = field.getName();
        AnnotationsAttribute fieldAnnotations = ((AnnotationsAttribute)field.getAttribute(AnnotationsAttribute.visibleTag));
        final List<AnnotationDescriptor> annotationDescriptors =
            (fieldAnnotations != null) ? getAnnotationDescriptors(fieldAnnotations) : Collections.<AnnotationDescriptor>emptyList();
        fieldDescriptors.add(new FieldDescriptor(fieldName, field.getDescriptor(), annotationDescriptors));
      }
      functions.add(new AnnotatedClassDescriptor(classFile.getName(), classAnnotations, fieldDescriptors));
    }
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:ClassPathScanner.java

示例9: getClassFields

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
@Override
public List<FieldInfo> getClassFields(String classname, ConstPool cp) {
	final Field[] fields = clazz.getDeclaredFields();
	if (null == fields || 0 == fields.length) {
		return null;
	}
	final ArrayList<FieldInfo> ret = new ArrayList<FieldInfo>();
	for (Field f : fields) {
		final FieldInfo fi = new FieldInfo(cp, f.getName(), Descriptor.of(f.getClass()));
		ret.add(fi);
		fi.setAccessFlags(f.getModifiers());
	}
	return ret;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:15,代码来源:DalvikClassClassPath.java

示例10: addFields

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
private void addFields(ClassFile cfile, Class<?> clazz) {
	final Field[] fields = clazz.getDeclaredFields();
	if (null != fields && 0 < fields.length) {
		for (Field f : fields) {
			try {
				final FieldInfo fi = new FieldInfo(cfile.getConstPool(), f.getName(), Descriptor.of(f.getType()));
				fi.setAccessFlags(f.getModifiers());
				cfile.addField(fi);
			} catch (DuplicateMemberException e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:15,代码来源:DalvikClassClassPath.java

示例11: makeFieldCache

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
private void makeFieldCache(CtMember.Cache cache) {
	List<FieldInfo> list = getClassFile2().getFields();
	if (null == list) {
    	return;
    }
    int n = list.size();
    for (int i = 0; i < n; ++i) {
        FieldInfo finfo = (FieldInfo)list.get(i);
        CtField newField = new CtField(finfo, this);
        cache.addField(newField);
    }
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:13,代码来源:CtClassType.java

示例12: removeField

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
public void removeField(CtField f) throws NotFoundException {
    checkModify();
    FieldInfo fi = f.getFieldInfo2();
    ClassFile cf = getClassFile2();
    if (cf.getFields().remove(fi)) {
        getMembers().remove(f);
        gcConstPool = true;
    }
    else
        throw new NotFoundException(f.toString());
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:12,代码来源:CtClassType.java

示例13: addFieldHandlerField

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
private void addFieldHandlerField(ClassFile classfile)
		throws CannotCompileException {
	ConstPool cp = classfile.getConstPool();
	FieldInfo finfo = new FieldInfo(cp, HANDLER_FIELD_NAME,
	                                HANDLER_FIELD_DESCRIPTOR);
	finfo.setAccessFlags(AccessFlag.PRIVATE | AccessFlag.TRANSIENT);
	classfile.addField(finfo);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:FieldTransformer.java

示例14: discoverAndIntimateForFieldAnnotations

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
/**
   * Discovers Field Annotations
   * 
   * @param classFile
   */
  private void discoverAndIntimateForFieldAnnotations (ClassFile classFile) {
@SuppressWarnings("unchecked") 
List<FieldInfo> fields = classFile.getFields();
if (fields == null) {
	return;
}

for (FieldInfo fieldInfo : fields) {
	Set<Annotation> annotations = new HashSet<Annotation>();
	
	AnnotationsAttribute visible = (AnnotationsAttribute) fieldInfo.getAttribute(AnnotationsAttribute.visibleTag);
	AnnotationsAttribute invisible = (AnnotationsAttribute) fieldInfo.getAttribute(AnnotationsAttribute.invisibleTag);

	if (visible != null) {
		annotations.addAll(Arrays.asList(visible.getAnnotations()));
	}
	if (invisible != null) {
		annotations.addAll(Arrays.asList(invisible.getAnnotations()));
	}
	
	// now tell listeners
	for (Annotation annotation : annotations) {
		Set<FieldAnnotationDiscoveryListener> listeners = fieldAnnotationListeners.get(annotation.getTypeName());
		if (null == listeners) {
			continue;
		}
		
		for (FieldAnnotationDiscoveryListener listener : listeners) {
			listener.discovered(classFile.getName(), fieldInfo.getName(), annotation.getTypeName());
		}
	}
}
  }
 
开发者ID:guci314,项目名称:playorm,代码行数:39,代码来源:Discoverer.java

示例15: scanFields

import javassist.bytecode.FieldInfo; //导入依赖的package包/类
protected void scanFields(ClassFile cf) {
    List<ClassFile> fields = cf.getFields();
    if (fields == null)
        return;
    for (Object obj : fields) {
        FieldInfo field = (FieldInfo) obj;
        AnnotationsAttribute visible = (AnnotationsAttribute) field.getAttribute(AnnotationsAttribute.visibleTag);
        AnnotationsAttribute invisible = (AnnotationsAttribute) field
                .getAttribute(AnnotationsAttribute.invisibleTag);
        if (visible != null)
            populate(visible.getAnnotations(), cf.getName());
        if (invisible != null)
            populate(invisible.getAnnotations(), cf.getName());
    }
}
 
开发者ID:audit4j,项目名称:audit4j-core,代码行数:16,代码来源:AnnotationDB.java


注:本文中的javassist.bytecode.FieldInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。