gpt4 book ai didi

edu.umd.cs.findbugs.ba.XField类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 16:42:40 58 4
gpt4 key购买 nike

本文整理了Java中edu.umd.cs.findbugs.ba.XField类的一些代码示例,展示了XField类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XField类的具体详情如下:
包路径:edu.umd.cs.findbugs.ba.XField
类名称:XField

XField介绍

[英]Abstract representation of a field. Note that this is called "XField" to distinguish it from BCEL's Field class. Also, you can think of the "X" as expanding to "Instance" or "Static".

This interface and its implementations exist because Field objects in BCEL are awkward to deal with. They are not Comparable, it is difficult to find out what class they belong to, etc.

If the resolved() method returns true, then any information queried from this object can be assumed to be accurate. If the resolved() method returns false, then FindBugs can't find the field and any information other than name/signature/etc. cannot be trusted.
[中]字段的抽象表示。请注意,这被称为“XField”,以区别于BCEL的Field类。此外,您可以将“X”视为扩展到“实例”或“静态”。
这个接口及其实现之所以存在,是因为BCEL中的字段对象难以处理。它们是不可比较的,很难找出它们属于哪个阶级等等。
如果resolved()方法返回true,则可以假定从此对象查询的任何信息都是准确的。如果resolved()方法返回false,则FindBugs无法找到该字段,并且除了名称/签名/等之外的任何信息都不可信。

代码示例

代码示例来源:origin: spotbugs/spotbugs

public static FieldAnnotation fromXField(XField fieldDescriptor) {
  return new FieldAnnotation(fieldDescriptor.getClassName(), fieldDescriptor.getName(), fieldDescriptor.getSignature(),
      fieldDescriptor.getSourceSignature(), fieldDescriptor.isStatic());
}

代码示例来源:origin: spotbugs/spotbugs

if (!fld.isStatic() && (fld.isPublic() || fld.isProtected())) {
  fieldName = fld.getName();
  if (fieldName.length() == 1) {
    continue;
    if (maskingField.isStatic() || maskingField.isFinal()) {
      priority++;
    } else if (fld.getSignature().charAt(0) == 'L' && !fld.getSignature().startsWith("Ljava/lang/")
        || fld.getSignature().charAt(0) == '[') {
      priority--;
    if (!fld.getSignature().equals(maskingField.getSignature())) {
      priority += 2;
    } else if (fld.getAccessFlags() != maskingField.getAccessFlags()) {
      priority++;
    if (fld.isSynthetic() || fld.getName().indexOf('$') >= 0) {
      priority++;
    FieldAnnotation maskedFieldAnnotation = FieldAnnotation.fromFieldDescriptor(fld.getFieldDescriptor());
    BugInstance bug = new BugInstance(this, "MF_CLASS_MASKS_FIELD", priority).addClass(this).addField(fa)
        .describe("FIELD_MASKING").addField(maskedFieldAnnotation).describe("FIELD_MASKED");

代码示例来源:origin: spotbugs/spotbugs

@Override
public int compareTo(AvailableLoad other) {
  int cmp = field.compareTo(other.field);
  if (cmp != 0) {
    return cmp;
  } else if (reference == other.reference) {
    return 0;
  } else if (reference == null) {
    return -1;
  } else if (other.reference == null) {
    return 1;
  } else {
    return reference.compareTo(other.reference);
  }
}

代码示例来源:origin: spotbugs/spotbugs

@Override
public void visit(Field obj) {
  XField xField = getXField();
  if(!xField.isStatic() && (xField.isPrivate() || xField.isFinal()) && xField.isReferenceType()) {
    allowedFields.add(xField.getFieldDescriptor());
  }
}

代码示例来源:origin: spotbugs/spotbugs

private boolean interesting(XField f) {
  if (!f.isPublic() && !f.isProtected()) {
    return false;
  }
  if (!f.isStatic() || f.isSynthetic() || f.isVolatile()) {
    return false;
  }
  if (!f.isFinal()) {
    return true;
  }
  boolean isArray = f.getSignature().charAt(0) == '[';
  if (!(isArray || isCollection(f.getSignature()))) {
    return false;
  }
  return true;
}

代码示例来源:origin: spotbugs/spotbugs

Set<String> fieldNamesSet = new HashSet<>();
for (XField f : data.writtenNonNullFields) {
  fieldNamesSet.add(f.getName());
XFactory xFactory = AnalysisContext.currentXFactory();
for (XField f : AnalysisContext.currentXFactory().allFields()) {
  ClassDescriptor classDescriptor = f.getClassDescriptor();
  if (currentAnalysisContext.isApplicationClass(classDescriptor) && !currentAnalysisContext.isTooBig(classDescriptor)
      && !xFactory.isReflectiveClass(classDescriptor)) {
for (Iterator<XField> i = declaredFields.iterator(); i.hasNext();) {
  XField f = i.next();
  if (f.isSynthetic() && !f.getName().startsWith("this$") || f.getName().startsWith("_")) {
    i.remove();
  if (i.next().isStatic()) {
    i.remove();
  nullOnlyFieldNames.add(f.getName());
  classContainingNullOnlyFields.add(f.getClassDescriptor());
  int increment = 3;
  Collection<ProgramPoint> assumedNonNullAt = data.assumedNonNull.get(f);
  } else if (nullOnlyFieldNames.getCount(f.getName()) > 8) {
    assumeReflective.add(f);
  } else if (classContainingNullOnlyFields.getCount(f.getClassDescriptor()) > 4) {
    assumeReflective.add(f);
  } else if (classContainingNullOnlyFields.getCount(f.getClassDescriptor()) > 2 && f.getName().length() == 1) {
    assumeReflective.add(f);

代码示例来源:origin: spotbugs/spotbugs

checkWriteToStaticFromInstanceMethod: if (f.getName().indexOf("class$") != 0) {
  int priority = LOW_PRIORITY;
  if (f.isReferenceType()) {
    try {
      ValueNumberDataflow vnaDataflow = getClassContext().getValueNumberDataflow(getMethod());
  if (getClassName().indexOf('$') != -1 || BCELUtil.isSynthetic(getMethod()) || f.isSynthetic()
      || f.getName().indexOf('$') >= 0) {
    priority++;
  if (f.getName().indexOf("DEBUG") >= 0 || f.getName().indexOf("VERBOSE") >= 0 && "Z".equals(f.getSignature())) {
    priority++;
    priority++;
      if (f.isReferenceType()) {
        FieldDescriptor fieldInfo = f.getFieldDescriptor();
        String dottedClass = DeepSubtypeAnalysis.getComponentClass(fieldInfo.getSignature());
        JavaClass fieldClass = Repository.lookupClass(dottedClass);
  XField f = item.getXField();
  if (f != null
      && !f.isStatic()
      && !data.nullTested.contains(f)
      && !((data.writtenInConstructorFields.contains(f) || data.writtenInInitializationFields.contains(f)) && data.writtenNonNullFields
if (getMethod().isStatic() == f.isStatic()
    && (isConstructor || data.calledFromConstructors.contains(getMethodName() + ":" + getMethodSig())
        || "init".equals(getMethodName()) || "initialize".equals(getMethodName())

代码示例来源:origin: spotbugs/spotbugs

boolean isFinal = f.isFinal();
String className = f.getClassName();
String fieldSig = f.getSignature();
String fieldName = f.getName();
boolean couldBeFinal = !isFinal && !notFinal.contains(f);
  XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, f.getClassDescriptor());
  movedOutofInterface = couldBePackage && xClass.isInterface();
} catch (CheckedAnalysisException e) {

代码示例来源:origin: spotbugs/spotbugs

if (xfield.isStatic() || xfield.isPublic() || xfield.isVolatile() || xfield.isFinal()) {
  continue;
    if (!instanceClassName.equals(xfield.getClassName())) {
      xfield = XFactory.getExactXField(instanceClassName, xfield.getName(), xfield.getSignature(),
          xfield.isStatic());

代码示例来源:origin: spotbugs/spotbugs

public void killLoadsWithSimilarName(String className, String methodName) {
  if (!REDUNDANT_LOAD_ELIMINATION) {
    return;
  }
  String packageName = extractPackageName(className);
  HashSet<AvailableLoad> killMe = new HashSet<>();
  for (AvailableLoad availableLoad : getAvailableLoadMap().keySet()) {
    XField field = availableLoad.getField();
    String fieldPackageName = extractPackageName(field.getClassName());
    if (packageName.equals(fieldPackageName) && field.isStatic()
        && methodName.toLowerCase().indexOf(field.getName().toLowerCase()) >= 0) {
      killMe.add(availableLoad);
    }
  }
  killAvailableLoads(killMe);
}

代码示例来源:origin: com.mebigfatguy.fb-contrib/fb-contrib

Set<SourceLineAnnotation> sla = memberSourceLineAnnotations.get(field.getName());
if (sla == null) {
  sla = new HashSet<>();
  memberSourceLineAnnotations.put(field.getName(), sla);
FQField fqField = new FQField(field.getClassName(), field.getName(), field.getSignature());
Set<String> commonSupers = memberCollections.get(fqField);
if (commonSupers == null) {

代码示例来源:origin: spotbugs/spotbugs

&& !f.isSynthetic() && obj.sameValue(putFieldObj) && x != null) {
  priority++;
if (f.isVolatile()) {
  priority++;
int matches = 0;
for (XField f2 : x.getXFields()) {
  if (!f.equals(f2) && !f2.isStatic() && !f2.isFinal() && !f2.isSynthetic()
      && f2.getSignature().equals(f.getSignature())) {
    double distance = EditDistance.editDistanceRatio(f.getName(), f2.getName());
    matches++;
    if (minimumDistance > distance) {

代码示例来源:origin: spotbugs/spotbugs

if (f.getName().startsWith("this$")) {
  return NullnessAnnotation.NONNULL;

代码示例来源:origin: spotbugs/spotbugs

XField xfield = Hierarchy.findXField(field.getClassName(), field.getFieldName(), field.getFieldSig(),
    field.isStatic());
if (!xfield.isResolved()) {
  return;
if (!xfield.isStatic()) {
  return;
if (xfield.getName().startsWith("class$") || xfield.getName().startsWith("array$")) {
  if (DEBUG) {
    System.out.println("Ignoring field " + xfield.getName());
String signature = xfield.getSignature();
if (!signature.startsWith("[") && !signature.startsWith("L")) {
  if (DEBUG) {
    System.out.println("Ignoring non-reference field " + xfield.getName());
if (!sawGetStaticAfterPutStatic && xfield.isVolatile()) {
  return;

代码示例来源:origin: spotbugs/spotbugs

if (field.isFinal()) {
  Item summary = AnalysisContext.currentAnalysisContext().getFieldSummary().getSummary(field);
  if (summary.isNull()) {
if ("java.util.logging.Level".equals(field.getClassName()) && "SEVERE".equals(field.getName())
    || "org.apache.log4j.Level".equals(field.getClassName())
    && ("ERROR".equals(field.getName()) || "FATAL".equals(field.getName()))) {
  getFrame().toExceptionValues();
if (field.getName().startsWith("class$")) {
  produce(IsNullValue.nonNullValue());
  return;

代码示例来源:origin: spotbugs/spotbugs

public static Type getType(XField xfield) {
  Type t = Type.getType(xfield.getSignature());
  if (!(t instanceof ReferenceType)) {
    return t;
    if (database != null) {
      FieldStoreType property = database.getProperty(xfield
          .getFieldDescriptor());
      if (property != null) {
        loadType = property.getLoadType(loadType);
      Item summary = fieldSummary.getSummary(xfield);
      if (summary != null) {
        if (xfield.isFinal() && summary.isNull()) {
          return TypeFrame.getNullType();
  String sourceSignature = xfield.getSourceSignature();
  if (sourceSignature != null && loadType instanceof ObjectType) {
    loadType = GenericUtilities.merge(

代码示例来源:origin: find-sec-bugs/find-sec-bugs

if(field.getClassName().endsWith("SecurityBypasser$AllHosts$") && field.getName().equals("MODULE$")) {
  bugReporter.reportBug(new BugInstance(this, WEAK_HOSTNAME_VERIFIER_TYPE, Priorities.NORMAL_PRIORITY) //
      .addClass(this).addMethod(this).addSourceLine(this));
else if(field.getClassName().endsWith("SecurityBypasser$AllTM$") && field.getName().equals("MODULE$")) {
  bugReporter.reportBug(new BugInstance(this, WEAK_TRUST_MANAGER_TYPE, Priorities.NORMAL_PRIORITY) //
      .addClass(this).addMethod(this).addSourceLine(this));

代码示例来源:origin: spotbugs/spotbugs

private BugInstance addClassFieldAndAccess(BugInstance instance, XField f) {
  if (data.writtenNonNullFields.contains(f) && data.readFields.contains(f)) {
    throw new IllegalArgumentException("No information for fields that are both read and written nonnull");
  }
  instance.addClass(f.getClassName()).addField(f);
  if (data.fieldAccess.containsKey(f)) {
    instance.add(data.fieldAccess.get(f));
  }
  return instance;
}

代码示例来源:origin: spotbugs/spotbugs

private MethodCall getMethodCall(MethodDescriptor methodDescriptorOperand) {
  Item objItem = getStack().getStackItem(getNumberArguments(methodDescriptorOperand.getSignature()));
  if (isNew(objItem)) {
    return new MethodCall(methodDescriptorOperand, TARGET_NEW);
  }
  if (objItem.getRegisterNumber() == 0 && !getMethod().isStatic()) {
    return new MethodCall(methodDescriptorOperand, constructor ? TARGET_NEW : TARGET_THIS);
  }
  XField xField = objItem.getXField();
  if (xField != null) {
    if (classInit && xField.isStatic() && xField.getClassDescriptor().getClassName().equals(getClassName())) {
      return new MethodCall(methodDescriptorOperand, TARGET_NEW);
    }
    if (!getMethodDescriptor().isStatic() && objItem.getFieldLoadedFromRegister() == 0
        && allowedFields.contains(xField.getFieldDescriptor())) {
      fieldsModifyingMethods.add(getMethodDescriptor());
      return new MethodCall(methodDescriptorOperand, xField.getFieldDescriptor());
    }
  }
  return new MethodCall(methodDescriptorOperand, TARGET_OTHER);
}

代码示例来源:origin: spotbugs/spotbugs

boolean hasUpdates = false;
for (XField f : xClass.getXFields()) {
  if (!f.isStatic()) {
    if (!f.isFinal() && !f.isSynthetic()) {
      hasMutableField = true;
      if (unreadFields.isWrittenOutsideOfInitialization(f)) {
    String signature = f.getSignature();
    if (signature.startsWith("Ljava/util/concurrent") || signature.startsWith("Ljava/lang/StringB")
        || signature.charAt(0) == '[' || signature.indexOf("Map") >= 0 || signature.indexOf("List") >= 0

58 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com