コード例 #1
0
  public FieldOptimizationInfo(Clazz clazz, Field field) {
    int accessFlags = field.getAccessFlags();

    isWritten = isRead = (accessFlags & ClassConstants.INTERNAL_ACC_VOLATILE) != 0;

    if ((accessFlags & ClassConstants.INTERNAL_ACC_STATIC) != 0) {
      // See if we can initialize the static field with a constant value.
      field.accept(clazz, new AllAttributeVisitor(this));
    }

    if ((accessFlags & ClassConstants.INTERNAL_ACC_FINAL) == 0 && value == null) {
      // Otherwise initialize the non-final field with the default value.
      value = initialValue(field.getDescriptor(clazz));
    }
  }
コード例 #2
0
  public static FieldOptimizationInfo getFieldOptimizationInfo(Field field) {
    Object visitorInfo = field.getVisitorInfo();

    return visitorInfo instanceof FieldOptimizationInfo
        ? (FieldOptimizationInfo) visitorInfo
        : null;
  }
コード例 #3
0
 public static void setFieldOptimizationInfo(Clazz clazz, Field field) {
   field.setVisitorInfo(new FieldOptimizationInfo(clazz, field));
 }