public soot.SootResolver soot_SootResolver() { if (instance_soot_SootResolver == null) { synchronized (this) { if (instance_soot_SootResolver == null) instance_soot_SootResolver = new soot.SootResolver(g); } } return instance_soot_SootResolver; } protected void release_soot_SootResolver() {
public void reResolve(SootClass cl, int newResolvingLevel) { int resolvingLevel = cl.resolvingLevel(); if (resolvingLevel >= newResolvingLevel) { return; } reResolveHierarchy(cl, SootClass.HIERARCHY); cl.setResolvingLevel(newResolvingLevel); addToResolveWorklist(cl, resolvingLevel); processResolveWorklist(); }
while (!worklist[i].isEmpty()) { SootClass sc = worklist[i].pop(); if (resolveEverything()) { // Whole program mode boolean onlySignatures = sc.isPhantom() || (Options.v().no_bodies_for_excluded() && Scene.v().isExcluded(sc) && !Scene.v().getBasicClasses().contains(sc.getName())); if (onlySignatures) { bringToSignatures(sc); sc.setPhantomClass(); for (SootMethod m : sc.getMethods()) { bringToBodies(sc); bringToBodies(sc); break; case SootClass.SIGNATURES: bringToSignatures(sc); break; case SootClass.HIERARCHY: bringToHierarchy(sc); break;
public SootClass forceResolve(String className, int level) { boolean tmp = doneResolving; doneResolving = false; SootClass c; try { c = SootResolver.v().resolveClass(className, level); } finally { doneResolving = tmp; } return c; }
/** * Get the SootClass object corresponding to this RefType. * * @return the corresponding SootClass */ public SootClass getSootClass() { if (sootClass == null) { // System.out.println( "wrning: "+this+" has no sootclass" ); sootClass = SootResolver.v().makeClassRef(className); } return sootClass; }
/** * Resolves the given class. Depending on the resolver settings, may decide to resolve other classes as well. If the class * has already been resolved, just returns the class that was already resolved. */ public SootClass resolveClass(String className, int desiredLevel) { SootClass resolvedClass = null; try { resolvedClass = makeClassRef(className); addToResolveWorklist(resolvedClass, desiredLevel); processResolveWorklist(); return resolvedClass; } catch (SootClassNotFoundException e) { // remove unresolved class and rethrow if (resolvedClass != null) { assert resolvedClass.resolvingLevel() == SootClass.DANGLING; Scene.v().removeClass(resolvedClass); } throw e; } }
SootResolver.v().makeClassRef(sootTypeName); SootResolver.v().resolveClass(sootTypeName, SootClass.SIGNATURES);
public void outAThrowsClause(AThrowsClause node) { List l = (List) mProductions.removeLast(); Iterator it = l.iterator(); List<SootClass> exceptionClasses = new ArrayList<SootClass>(l.size()); while (it.hasNext()) { String className = (String) it.next(); exceptionClasses.add(mResolver.makeClassRef(className)); } mProductions.addLast(exceptionClasses); } }
private void addToResolveWorklist(String className, int level) { addToResolveWorklist(makeClassRef(className), level); } private void addToResolveWorklist(SootClass sc, int desiredLevel) {
bringToHierarchy(sc); if(Options.v().debug_resolver()) G.v().out.println("bringing to SIGNATURES: "+sc); addToResolveWorklist( f.getType(), SootClass.HIERARCHY ); addToResolveWorklist( m.getReturnType(), SootClass.HIERARCHY ); for( Iterator ptypeIt = m.getParameterTypes().iterator(); ptypeIt.hasNext(); ) { final Type ptype = (Type) ptypeIt.next(); addToResolveWorklist( ptype, SootClass.HIERARCHY ); addToResolveWorklist( exception, SootClass.HIERARCHY ); addToResolveWorklist(sc.getSuperclass(), SootClass.SIGNATURES); for( Iterator ifaceIt = sc.getInterfaces().iterator(); ifaceIt.hasNext(); ) { final SootClass iface = (SootClass) ifaceIt.next(); addToResolveWorklist(iface, SootClass.SIGNATURES);
bringToSignatures(sc); if(Options.v().debug_resolver()) G.v().out.println("bringing to BODIES: "+sc); addToResolveWorklist((String) o, SootClass.HIERARCHY); } else if( o instanceof Type ) { addToResolveWorklist((Type) o, SootClass.HIERARCHY); } else throw new RuntimeException(o.toString()); addToResolveWorklist((String) o, SootClass.SIGNATURES); } else if( o instanceof Type ) { addToResolveWorklist((Type) o, SootClass.SIGNATURES); } else throw new RuntimeException(o.toString());
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); }
protected void addToResolveWorklist(Type type, int level) { // We go from Type -> SootClass directly, since RefType.getSootClass // calls makeClassRef anyway if (type instanceof RefType) { addToResolveWorklist(((RefType) type).getSootClass(), level); } else if (type instanceof ArrayType) { addToResolveWorklist(((ArrayType) type).baseType, level); } // Other types ignored }
/** * Signatures - we know the signatures of all methods and fields requires at least Hierarchy for all referred to types in * these signatures. */ protected void bringToSignatures(SootClass sc) { if (sc.resolvingLevel() >= SootClass.SIGNATURES) { return; } bringToHierarchy(sc); if (Options.v().debug_resolver()) { logger.debug("bringing to SIGNATURES: " + sc); } sc.setResolvingLevel(SootClass.SIGNATURES); bringToSignaturesUnchecked(sc); }
/** * Bodies - we can now start loading the bodies of methods for all referred to methods and fields in the bodies, requires * signatures for the method receiver and field container, and hierarchy for all other classes referenced in method * references. Current implementation does not distinguish between the receiver and other references. Therefore, it is * conservative and brings all of them to signatures. But this could/should be improved. */ protected void bringToBodies(SootClass sc) { if (sc.resolvingLevel() >= SootClass.BODIES) { return; } bringToSignatures(sc); if (Options.v().debug_resolver()) { logger.debug("bringing to BODIES: " + sc); } sc.setResolvingLevel(SootClass.BODIES); bringToBodiesUnchecked(sc); }
reResolveHierarchy(sc, SootClass.HIERARCHY);
@Override public void visitOuterClass(String owner, String name, String desc) { if (name != null) { klass.addTag(new EnclosingMethodTag(owner, name, desc)); } owner = AsmUtil.toQualifiedName(owner); deps.add(RefType.v(owner)); klass.setOuterClass(SootResolver.v().makeClassRef(owner)); }
public SootClass loadClass(String className, int desiredLevel) { /* * if(Options.v().time()) Main.v().resolveTimer.start(); */ setPhantomRefs(true); // SootResolver resolver = new SootResolver(); SootResolver resolver = SootResolver.v(); SootClass toReturn = resolver.resolveClass(className, desiredLevel); setPhantomRefs(false); return toReturn; /* * if(Options.v().time()) Main.v().resolveTimer.end(); */ }
/** * Resolves the given class. Depending on the resolver settings, may * decide to resolve other classes as well. If the class has already * been resolved, just returns the class that was already resolved. * */ public SootClass resolveClass(String className, int desiredLevel) { SootClass resolvedClass = makeClassRef(className); addToResolveWorklist(resolvedClass, desiredLevel); processResolveWorklist(); return resolvedClass; }
public void outAThrowsClause(AThrowsClause node) { List l = (List) mProductions.removeLast(); Iterator it = l.iterator(); List<SootClass> exceptionClasses = new ArrayList<SootClass>(l.size()); while (it.hasNext()) { String className = (String) it.next(); exceptionClasses.add(mResolver.makeClassRef(className)); } mProductions.addLast(exceptionClasses); }