class UnreachableFieldsTagger extends SceneTransformer {
  public UnreachableFieldsTagger(Singletons.Global g) {
  }

  public static UnreachableFieldsTagger v() {
    return G.v().soot_jimple_toolkits_annotation_fields_UnreachableFieldsTagger();
  }

  protected void internalTransform(String phaseName, Map options) {<FILL_FUNCTION_BODY>}

}


    // make list of all fields
    ArrayList<SootField> fieldList = new ArrayList<SootField>();

    Iterator getClassesIt = Scene.v().getApplicationClasses().iterator();
    while (getClassesIt.hasNext()) {
      SootClass appClass = (SootClass) getClassesIt.next();
      // System.out.println("class to check: "+appClass);
      Iterator getFieldsIt = appClass.getFields().iterator();
      while (getFieldsIt.hasNext()) {
        SootField field = (SootField) getFieldsIt.next();
        // System.out.println("adding field: "+field);
        fieldList.add(field);
      }
    }

    // from all bodies get all use boxes and eliminate used fields
    getClassesIt = Scene.v().getApplicationClasses().iterator();
    while (getClassesIt.hasNext()) {
      SootClass appClass = (SootClass) getClassesIt.next();
      Iterator mIt = appClass.getMethods().iterator();
      while (mIt.hasNext()) {
        SootMethod sm = (SootMethod) mIt.next();
        // System.out.println("checking method: "+sm.getName());
        if (!sm.hasActiveBody() || !Scene.v().getReachableMethods().contains(sm)) {
          continue;
        }
        Body b = sm.getActiveBody();

        Iterator usesIt = b.getUseBoxes().iterator();
        while (usesIt.hasNext()) {
          ValueBox vBox = (ValueBox) usesIt.next();
          Value v = vBox.getValue();
          if (v instanceof FieldRef) {
            FieldRef fieldRef = (FieldRef) v;
            SootField f = fieldRef.getField();

            if (fieldList.contains(f)) {
              int index = fieldList.indexOf(f);
              fieldList.remove(index);
              // System.out.println("removed field: "+f);
            }

          }
        }

      }
    }

    // tag unused fields
    Iterator<SootField> unusedIt = fieldList.iterator();
    while (unusedIt.hasNext()) {
      SootField unusedField = unusedIt.next();
      unusedField.addTag(new StringTag("Field " + unusedField.getName() + " is not used!", "Unreachable Fields"));
      unusedField.addTag(new ColorTag(ColorTag.RED, true, "Unreachable Fields"));
      // System.out.println("tagged field: "+unusedField);

    }
  
<methods>public non-sealed void <init>() ,public final void transform(java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(java.lang.String) ,public final void transform() <variables>