class EncapsulatedObjectAnalysis // extends ForwardFlowAnalysis
{
  private static final Logger logger = LoggerFactory.getLogger(EncapsulatedObjectAnalysis.class);
  List cachedClasses;
  List<SootMethod> objectPureMethods;
  List<SootMethod> objectPureInitMethods;

  public EncapsulatedObjectAnalysis() {
    cachedClasses = new ArrayList();
    objectPureMethods = new ArrayList<SootMethod>();
    objectPureInitMethods = new ArrayList<SootMethod>();
  }

  public boolean isMethodPureOnObject(SootMethod sm) {<FILL_FUNCTION_BODY>}

  public boolean isInitMethodPureOnObject(SootMethod sm) {
    // logger.debug("Testing Init Method Encapsulation: " + sm + " Encapsulated: ");
    if (isMethodPureOnObject(sm)) {
      boolean ret = objectPureInitMethods.contains(sm);
      // logger.debug(""+ret);
      return ret;
    }
    // logger.debug("false");
    return false;
  }

  public List<SootMethod> getObjectPureMethodsSoFar() {
    return objectPureMethods;
  }
}

    if (!cachedClasses.contains(sm.getDeclaringClass()) && sm.isConcrete()) // NOT A COMPLETE SOLUTION (ignores subclassing)
    {
      SootMethod initMethod = null;
      Collection methods = sm.getDeclaringClass().getMethods();
      Iterator methodsIt = methods.iterator();
      List<SootMethod> mayBePureMethods = new ArrayList<SootMethod>(methods.size());
      while (methodsIt.hasNext()) {
        SootMethod method = (SootMethod) methodsIt.next();
        if (method.isConcrete()) {
          if (method.getSubSignature().startsWith("void <init>")) {
            initMethod = method;
          }
          Body b = method.retrieveActiveBody();
          EncapsulatedMethodAnalysis ema
              = new EncapsulatedMethodAnalysis(ExceptionalUnitGraphFactory.createExceptionalUnitGraph(b));
          if (ema.isPure()) {
            mayBePureMethods.add(method);
          }
        }
      }

      if (mayBePureMethods.size() == methods.size()) {
        objectPureMethods.addAll(mayBePureMethods);
      } else if (initMethod != null) {
        objectPureMethods.add(initMethod);
      }
      if (initMethod != null) {
        objectPureInitMethods.add(initMethod);
      }
    }

    return objectPureMethods.contains(sm);
  
<no_super_class>