gpt4 book ai didi

edu.umd.cs.findbugs.ba.XField.isStatic()方法的使用及代码示例

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

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

XField.isStatic介绍

暂无

代码示例

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

public boolean isStatic() {
  return field.isStatic();
}

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

@Override
public void visit(Field obj) {
  super.visit(obj);
  XField f = XFactory.createXField(this);
  if (checkForInitialization(f) && !f.isSynthetic()) {
    if (f.isStatic()) {
      nonnullStaticFields.add(f);
    } else {
      nonnullFields.add(f);
    }
  }
}

代码示例来源: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: spotbugs/spotbugs

/**
 * Add a field annotation for an XField.
 *
 * @param xfield
 *            the XField
 * @return this object
 */
@Nonnull
public BugInstance addOptionalField(@CheckForNull XField xfield) {
  if (xfield == null) {
    return this;
  }
  return addField(xfield.getClassName(), xfield.getName(), xfield.getSignature(), xfield.isStatic());
}

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

/**
 * Add a field annotation for an XField.
 *
 * @param xfield
 *            the XField
 * @return this object
 */
@Nonnull
public BugInstance addField(XField xfield) {
  return addField(xfield.getClassName(), xfield.getName(), xfield.getSignature(), xfield.isStatic());
}

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

if (!field.isStatic()) {
  String classSig = "L" + javaClass.getClassName().replace('.', '/') + ";";

代码示例来源: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

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

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

boolean hasUpdates = false;
for (XField f : xClass.getXFields()) {
  if (!f.isStatic()) {
    if (!f.isFinal() && !f.isSynthetic()) {
      hasMutableField = true;

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

/**
 * Look up the field referenced by given FieldInstruction, returning it as
 * an {@link XField XField} object.
 *
 * @param fins
 *            the FieldInstruction
 * @param cpg
 *            the ConstantPoolGen used by the class containing the
 *            instruction
 * @return an XField object representing the field, or null if no such field
 *         could be found
 */
public static @CheckForNull XField findXField(FieldInstruction fins, @Nonnull ConstantPoolGen cpg) {
  String className = fins.getClassName(cpg);
  String fieldName = fins.getFieldName(cpg);
  String fieldSig = fins.getSignature(cpg);
  boolean isStatic = (fins.getOpcode() == Const.GETSTATIC || fins.getOpcode() == Const.PUTSTATIC);
  XField xfield = findXField(className, fieldName, fieldSig, isStatic);
  short opcode = fins.getOpcode();
  if (xfield != null && xfield.isResolved()
      && xfield.isStatic() == (opcode == Const.GETSTATIC || opcode == Const.PUTSTATIC)) {
    return xfield;
  } else {
    return null;
  }
}

代码示例来源: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

if (f.isStatic()) {
  staticCount++;
} else if (!f.isPrivate()) {

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

@Override
public void visit(Code obj) {
  sawInitializeSuper = false;
  super.visit(obj);
  fieldSummary.setFieldsWritten(getXMethod(), touched);
  if (Const.CONSTRUCTOR_NAME.equals(getMethodName()) && sawInitializeSuper) {
    XClass thisClass = getXClass();
    for (XField f : thisClass.getXFields()) {
      if (!f.isStatic() && !f.isFinal() && !touched.contains(f)) {
        OpcodeStack.Item item;
        char firstChar = f.getSignature().charAt(0);
        if (firstChar == 'L' || firstChar == '[') {
          item = OpcodeStack.Item.nullItem(f.getSignature());
        } else if (firstChar == 'I') {
          item = new OpcodeStack.Item("I", (Integer) 0);
        } else if (firstChar == 'J') {
          item = new OpcodeStack.Item("J", 0L);
        } else {
          item = new OpcodeStack.Item(f.getSignature());
        }
        fieldSummary.mergeSummary(f, item);
      }
    }
  }
  touched.clear();
}

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

if (xfield.isStatic()) {
  loadStaticField(xfield, obj);
} else {
if (xfield.isStatic()) {
  storeStaticField(xfield, obj, pushValue);
} else {

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

bugPattern = "RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN";
  priority = Priorities.NORMAL_PRIORITY;
} else if (xf != null && xf.isStatic() && xf.isFinal()) {
  bugPattern = "RC_REF_COMPARISON_BAD_PRACTICE";
  if (xf.isPublic() || !methodGen.isPublic()) {

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

/**
 * Called to indicate that a field load or store was encountered.
 *
 * @param cpIndex
 *            the constant pool index of the fieldref
 * @param isStatic
 *            true if it is a static field access
 * @param isLoad
 *            true if the access is a load
 */
private void setField(int cpIndex, boolean isStatic, boolean isLoad) {
  // We only allow one field access for an accessor method.
  accessCount++;
  if (accessCount != 1) {
    access = null;
    return;
  }
  ConstantPool cp = javaClass.getConstantPool();
  ConstantFieldref fieldref = (ConstantFieldref) cp.getConstant(cpIndex);
  ConstantClass cls = (ConstantClass) cp.getConstant(fieldref.getClassIndex());
  String className = cls.getBytes(cp).replace('/', '.');
  ConstantNameAndType nameAndType = (ConstantNameAndType) cp.getConstant(fieldref.getNameAndTypeIndex());
  String fieldName = nameAndType.getName(cp);
  String fieldSig = nameAndType.getSignature(cp);
  XField xfield = Hierarchy.findXField(className, fieldName, fieldSig, isStatic);
  if (xfield != null && xfield.isStatic() == isStatic && isValidAccessMethod(methodSig, xfield, isLoad)) {
    access = new InnerClassAccess(methodName, methodSig, xfield, isLoad);
  }
}

代码示例来源: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

int fr0 = item0.getFieldLoadedFromRegister();
int fr1 = item1.getFieldLoadedFromRegister();
if (field0 != null && field0.equals(field1) && (field0.isStatic() || fr0 != -1 && fr0 == fr1)) {
  int priority = NORMAL_PRIORITY;
  if (field0.isVolatile()) {

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

} else {
  for (XField f : c.getXFields()) {
    if (f.getName().equals(local.getName()) && (f.isStatic() || !getMethod().isStatic())) {
      bugReporter.reportBug(new BugInstance(this, "SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD",
          priority).addClassAndMethod(this).add(local).addField(f)

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

@Override
public void visitClassContext(ClassContext classContext) {
  if(!classContext.getJavaClass().isEnum() || !classContext.getJavaClass().isPublic()) {
    return;
  }
  boolean hasInterestingField = false;
  for(XField field : classContext.getXClass().getXFields()) {
    if(!field.isStatic() && !field.isFinal() && !field.isSynthetic()) {
      if(field.isPublic()) {
        reporter.reportBug(new BugInstance("ME_MUTABLE_ENUM_FIELD", NORMAL_PRIORITY).addClass(classContext.getJavaClass())
            .addField(field));
      } else {
        hasInterestingField = true;
      }
    }
  }
  if(hasInterestingField) {
    super.visitClassContext(classContext);
  }
}

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