public static boolean hasRecursiveField(SootClass sootClass) { Chain fields = sootClass.getFields(); for (Iterator iter = fields.iterator(); iter.hasNext();) { SootField sootField = (SootField) iter.next(); Type type = sootField.getType(); if (type instanceof RefType) { RefType refType = (RefType) type; SootClass sootClass2 = refType.getSootClass(); if (sootClass == sootClass2) { return true; } } } return false; }
public static List<SootField> getAllFields(SootClass sc) { // Get list of reachable methods declared in this class // Also get list of fields declared in this class List<SootField> allFields = new ArrayList<SootField>(); for (SootField field : sc.getFields()) { allFields.add(field); } // Add reachable methods and fields declared in superclasses SootClass superclass = sc; if (superclass.hasSuperclass()) { superclass = superclass.getSuperclass(); } while (superclass.hasSuperclass()) // we don't want to process Object { for (SootField scField : superclass.getFields()) { allFields.add(scField); } superclass = superclass.getSuperclass(); } return allFields; }
public ArrayList<SootField> findFinalFields() { // first thing is to get a list of all final fields in the class ArrayList<SootField> interestingFinalFields = new ArrayList<SootField>(); Iterator fieldIt = sootClass.getFields().iterator(); while (fieldIt.hasNext()) { SootField tempField = (SootField) fieldIt.next(); if (tempField.isFinal()) { // if its static final and method is static add if (tempField.isStatic() && sootMethod.getName().compareTo("<clinit>") == 0) { interestingFinalFields.add(tempField); } // if its non static and final and method is constructor add if ((!tempField.isStatic()) && sootMethod.getName().compareTo("<init>") == 0) { interestingFinalFields.add(tempField); } } } return interestingFinalFields; }
public static void retrieveAllNames() { if (namesHaveBeenRetrieved) { return; } // iterate through application classes, rename fields with junk for (SootClass c : soot.Scene.v().getApplicationClasses()) { nameList.add(c.getName()); for (SootMethod m : c.getMethods()) { nameList.add(m.getName()); } for (SootField m : c.getFields()) { nameList.add(m.getName()); } } namesHaveBeenRetrieved = true; }
private void handleClass(SootClass cl) { for (Iterator<SootField> fIt = cl.getFields().iterator(); fIt.hasNext();) { final SootField f = fIt.next(); if (!f.isStatic()) {
private Iterator getScopedFields() { // get the fields for this class and store them SootClass sootClass = methodNode.getDavaBody().getMethod().getDeclaringClass(); fields = sootClass.getFields(); return fields.iterator(); }
Iterator<SootField> fieldIt = c.getFields().iterator(); while (fieldIt.hasNext()) { SootField field = fieldIt.next();
Iterator<SootField> fieldIt = this.getFields().iterator(); int fieldCount = 0;
SootClass appClass = (SootClass) getClassesIt.next(); Iterator getFieldsIt = appClass.getFields().iterator(); while (getFieldsIt.hasNext()) { SootField field = (SootField) getFieldsIt.next();
while (classesIt.hasNext()) { SootClass appClass = (SootClass) classesIt.next(); Iterator fieldsIt = appClass.getFields().iterator(); while (fieldsIt.hasNext()) { SootField sf = (SootField) fieldsIt.next();
SootClass tempClass = (SootClass) it.next(); Chain tempChain = tempClass.getFields(); Iterator tempIt = tempChain.iterator(); while (tempIt.hasNext()) {
for (SootField sf : sc.getFields()) { if (minVersion >= Options.java_version_1_5) { break;
/** * Collect tags from all fields and methods of <code>sc</code>. If <code>includeBodies</code> is true, then tags are also * collected from method bodies. * * @param sc * The class from which to collect the tags. */ public void collectTags(SootClass sc, boolean includeBodies) { // tag the class collectClassTags(sc); // tag fields for (SootField sf : sc.getFields()) { collectFieldTags(sf); } // tag methods for (SootMethod sm : sc.getMethods()) { collectMethodTags(sm); if (!includeBodies || !sm.hasActiveBody()) { continue; } Body b = sm.getActiveBody(); collectBodyTags(b); } }
if (!baseClasses.contains(RefType.v("java.lang.Exception").getSootClass())) { for (SootClass baseClass : baseClasses) { for (Iterator baseFieldIt = baseClass.getFields().iterator(); baseFieldIt.hasNext();) { SootField baseField = (SootField) baseFieldIt.next(); if (!baseField.isStatic()) {
protected void bringToSignaturesUnchecked(SootClass sc) { for (SootField f : sc.getFields()) { addToResolveWorklist(f.getType(), SootClass.HIERARCHY); } for (SootMethod m : sc.getMethods()) { addToResolveWorklist(m.getReturnType(), SootClass.HIERARCHY); for (Type ptype : m.getParameterTypes()) { addToResolveWorklist(ptype, SootClass.HIERARCHY); } List<SootClass> exceptions = m.getExceptionsUnsafe(); if (exceptions != null) { for (SootClass exception : exceptions) { addToResolveWorklist(exception, SootClass.HIERARCHY); } } } // Bring superclasses to signatures reResolveHierarchy(sc, SootClass.SIGNATURES); }
m.setPhantom(true); for (SootField f : sc.getFields()) { f.setPhantom(true);
for (SootField sf : sm.getDeclaringClass().getFields()) { EquivalentValue fieldRefEqVal = InfoFlowAnalysis.getNodeForFieldRef(sm, sf); if (!infoFlowGraph.containsNode(fieldRefEqVal)) { for (SootField scField : superclass.getFields()) { EquivalentValue fieldRefEqVal = InfoFlowAnalysis.getNodeForFieldRef(sm, scField); if (!infoFlowGraph.containsNode(fieldRefEqVal)) {
/** * Emits the bytecode for all fields of the class */ protected void generateFields() { for (SootField f : sc.getFields()) { if (f.isPhantom()) { continue; } String name = f.getName(); String desc = toTypeDesc(f.getType()); String sig = null; if (f.hasTag("SignatureTag")) { SignatureTag genericSignature = (SignatureTag) f.getTag("SignatureTag"); sig = genericSignature.getSignature(); } Object value = getDefaultValue(f); int access = getModifiers(f.getModifiers(), f); FieldVisitor fv = cv.visitField(access, name, desc, sig, value); if (fv != null) { generateAnnotations(fv, f); generateAttributes(fv, f); fv.visitEnd(); } } }
throw new RuntimeException( "Trying to get field val$" + li.name() + " from some outer class but can't access the outer class of: " + currentClass.getName() + "!" + " current class contains fields: " + currentClass.getFields());