Extract all fields of {@code obj} that are of type {@link Monitor} and add them to
{@code monitors}.
502705
static void addMonitorFields(
      List<Monitor<?>> monitors, String id, TagList tags, Object obj) {
    try {
      final SortedTagList.Builder builder = SortedTagList.builder();
      builder.withTag("class", className(obj.getClass()));
      if (tags != null) {
        builder.withTags(tags);
      }
      if (id != null) {
        builder.withTag("id", id);
      }
      final TagList classTags = builder.build();

      final Set<Field> fields = Reflection.getAllFields(obj.getClass());
      for (Field field : fields) {
        if (isMonitorType(field.getType())) {
          field.setAccessible(true);
          final Monitor<?> m = (Monitor<?>) field.get(obj);
          if (m == null) {
            throw new NullPointerException("field " + field.getName()
                + " in class " + field.getDeclaringClass().getName()
                + " is null, all monitor fields must be"
                + " initialized before registering");
          }
          monitors.add(wrap(classTags, m));
        }
      }
    } catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }
555638
@SuppressWarnings("unchecked")
  static <T> Monitor<T> wrap(TagList tags, Monitor<T> monitor) {
    Monitor<T> m;
    if (monitor instanceof CompositeMonitor<?>) {
      m = new CompositeMonitorWrapper<>(tags, (CompositeMonitor<T>) monitor);
    } else {
      m = MonitorWrapper.create(tags, monitor);
    }
    return m;
  }
51969
@Override
  public void add(ApiType obj) {
    String key = keyFunc.apply(obj);
    lock.lock();
    try {
      ApiType oldObj = this.items.get(key);
      this.items.put(key, obj);
      this.updateIndices(oldObj, obj, key);
    } finally {
      lock.unlock();
    }
  }
116608
@GwtIncompatible("Class.getDeclaredFields")
	public ToStringBuilder addDeclaredFields() {
		Field[] fields = instance.getClass().getDeclaredFields();
		for(Field field : fields) {
			addField(field);
		}
		return this;
	}
652563
private Field[] getAllInstanceFields(final Object obj) {
		Field[] fields = instanceFieldsByClass.get(obj.getClass());

		if (fields == null) {
			List<Field> fieldList = ReflectionUtil.
					getAllFields(obj, excludeStatic, excludeTransient);
			fields = fieldList.toArray(new Field[fieldList.size()]);

			instanceFieldsByClass.put(obj.getClass(), fields);
		}

		return fields;
	}
485736
public static Object getField(Object obj, String name) {
    try {
      Class<? extends Object> klass = obj.getClass();
      do {
        try {
          Field field = klass.getDeclaredField(name);
          field.setAccessible(true);
          return field.get(obj);
        } catch (NoSuchFieldException e) {
          klass = klass.getSuperclass();
        }
      } while (klass != null);
      throw new RuntimeException(); // true no such field exception
    } catch (SecurityException e) {
      throw new RuntimeException(e);
    } catch (IllegalArgumentException e) {
      throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }
243522
private static List<Field> getFieldsList(final Class cls, final boolean declared) {
		$.checkNotNull(cls);

		final List<Field> allFields = new ArrayList<Field>();
		Class currentClass = cls;
		while (currentClass != null) {
			final Field[] declaredFields = declared ? currentClass.getDeclaredFields() : currentClass.getFields();
			for (Field field : declaredFields) {
				allFields.add(field);
			}
			currentClass = currentClass.getSuperclass();
		}
		return allFields;
	}
1244596
private int getFieldIndexes(ISyncHandler<?, ? extends ISyncableData> handler, String... syncNames)
	{
		int indexes = 0;
		for (String str : syncNames)
		{
			ObjectData od = handler.getObjectData(str);
			if (od != null)
				indexes |= 1 << od.getIndex();
		}
		return indexes;
	}
921593
private void processFields(final Object component, final Context context, final ContextDestroyer contextDestroyer) {
        Class<?> componentClass = component.getClass();
        while (componentClass != null && !componentClass.equals(Object.class)) {
            final Field[] fields = ClassReflection.getDeclaredFields(componentClass);
            if (fields != null && fields.length > 0) {
                processFields(component, fields, context, contextDestroyer);
            }
            componentClass = componentClass.getSuperclass();
        }
    }
687569
public void addListeners()
    {
        super.addListeners();
        
            // Link the screen field to the passed in record
        ((ReferenceField)this.getScreenRecord().getField(ClassInfoScreenRecord.CLASS_PROJECT_ID)).syncReference(this.getHeaderRecord());
        this.getScreenRecord().getField(ClassInfoScreenRecord.CLASS_PROJECT_ID).addListener(new FieldReSelectHandler(this));
        
        this.getMainRecord().addListener(new ExtractRangeFilter(ClassInfo.CLASS_NAME, this.getScreenRecord().getField(ClassInfoScreenRecord.NAME)));
        this.getScreenRecord().getField(ClassInfoScreenRecord.NAME).addListener(new FieldReSelectHandler(this));
        
        this.getMainRecord().addListener(new ExtractRangeFilter(ClassInfo.CLASS_PACKAGE, this.getScreenRecord().getField(ClassInfoScreenRecord.PACKAGE)));
        this.getScreenRecord().getField(ClassInfoScreenRecord.PACKAGE).addListener(new FieldReSelectHandler(this));
    }
88633
@SuppressWarnings({ "PMD.GuardLogStatement", "PMD.AvoidDuplicateLiterals" })
    public void add(Object obj) {
        synchronized (this) {
            running += 1;
            if (generators != null) {
                generators.put(obj, null);
                generatorTracking.finest(() -> "Added generator " + obj
                    + ", " + generators.size() + " generators registered: "
                    + generators.keySet());
            }
            if (running == 1) { // NOPMD, no, not using a constant for this.
                keepAlive = new Thread("GeneratorRegistry") {
                    @Override
                    public void run() {
                        try {
                            while (true) {
                                Thread.sleep(Long.MAX_VALUE);
                            }
                        } catch (InterruptedException e) {
                            // Okay, then stop
                        }
                    }
                };
                keepAlive.start();
            }
        }
    }
980622
def AddFXrefRead(self, method, classobj, field):
        
        if field not in self._fields:
            self._fields[field] = FieldClassAnalysis(field)
        self._fields[field].AddXrefRead(classobj, method)
1109018
@Override
    public void visitField(Field obj) {
        String fieldSig = obj.getSignature();
        if ("Ljavax/swing/JLabel;".equals(fieldSig)) {
            FieldAnnotation fa = FieldAnnotation.fromVisitedField(this);

            fieldLabels.add(XFactory.createXField(fa));
        }
    }
122361
private String[] getSourceLines(Method obj) {

        if (srcInited) {
            return sourceLines;
        }

        try {
            srcLineAnnotation = SourceLineAnnotation.forEntireMethod(getClassContext().getJavaClass(), obj);
            if (srcLineAnnotation != null) {
                SourceFinder sourceFinder = AnalysisContext.currentAnalysisContext().getSourceFinder();
                SourceFile sourceFile = sourceFinder.findSourceFile(srcLineAnnotation.getPackageName(), srcLineAnnotation.getSourceFile());
                try (BufferedReader sourceReader = new BufferedReader(new InputStreamReader(sourceFile.getInputStream(), StandardCharsets.UTF_8))) {

                    List<String> lines = new ArrayList<>(100);
                    String line;
                    while ((line = sourceReader.readLine()) != null) {
                        lines.add(line);
                    }
                    sourceLines = lines.toArray(new String[0]);
                }
            }
        } catch (IOException ioe) {
            // noop
        }

        srcInited = true;
        return sourceLines;
    }
1191061
def extractfields(data, commdct, objkey, fieldlists):
    """"""
    # TODO : this assumes that the field list identical for
    # each instance of the object. This is not true.
    # So we should have a field list for each instance of the object
    # and map them with a zip
    objindex = data.dtls.index(objkey)
    objcomm = commdct[objindex]
    objfields = []
    # get the field names of that object
    for dct in objcomm[0:]:
        try:
            thefieldcomms = dct['field']
            objfields.append(thefieldcomms[0])
        except KeyError as err:
            objfields.append(None)
    fieldindexes = []
    for fieldlist in fieldlists:
        fieldindex = []
        for item in fieldlist:
            if isinstance(item, int):
                fieldindex.append(item)
            else:
                fieldindex.append(objfields.index(item) + 0)
                # the index starts at 1, not at 0
        fieldindexes.append(fieldindex)
    theobjects = data.dt[objkey]
    fieldcontents = []
    for theobject, fieldindex in zip(theobjects, fieldindexes):
        innerlst = []
        for item in fieldindex:
            try:
                innerlst.append(theobject[item])
            except IndexError as err:
                break
        fieldcontents.append(innerlst)
        # fieldcontents.append([theobject[item] for item in fieldindex])
    return fieldcontents
747784
private final Field[] getFields (Class<? extends Object> cls) {
    	Field[] ret = SEEN_CLASSES.get(cls);
        if (ret != null) {
            return ret;
        }

        List<Field> retL = new ArrayList<Field>();
        for (Field f: cls.getDeclaredFields ()) {
        	if (!isSimpleType(f)) {
        		retL.add(f);
        		f.setAccessible(true);
        	}
        }

        //the 2nd case can occur if the incoming object is of type Object.class
        //--> See Test_084_SerailizationBugRefToPM.
        if (cls.getSuperclass() != Object.class && cls != Object.class) {
        	for (Field f: getFields(cls.getSuperclass())) {
        		retL.add(f);
        	}
        }
        ret = retL.toArray(new Field[retL.size()]);
        SEEN_CLASSES.put(cls, ret);
        return ret;
    }
1122874
@Override
    public void visitField(Field obj) {
        if (checkConfusedName(obj.getName(), obj.getSignature())) {
            bugReporter.reportBug(new BugInstance(this, BugType.CNC_COLLECTION_NAMING_CONFUSION.name(), NORMAL_PRIORITY).addClass(this).addField(this)
                    .addString(obj.getName()));
        }
    }