public void outAFile(AFile node) { List implementsList = null; String superClass = null; String classType = null; if (node.getImplementsClause() != null) { implementsList = (List) mProductions.removeLast(); } if (node.getExtendsClause() != null) { superClass = (String) mProductions.removeLast(); } classType = (String) mProductions.removeLast(); int modifierFlags = processModifiers(node.getModifier()); if (classType.equals("interface")) { modifierFlags |= Modifier.INTERFACE; } mSootClass.setModifiers(modifierFlags); if (superClass != null) { mSootClass.setSuperclass(mResolver.makeClassRef(superClass)); } if (implementsList != null) { Iterator implIt = implementsList.iterator(); while (implIt.hasNext()) { SootClass interfaceClass = mResolver.makeClassRef((String) implIt.next()); mSootClass.addInterface(interfaceClass); } } mProductions.addLast(mSootClass); }
public void outAFile(AFile node) { // not not pop members; they have been taken care of. List implementsList = null; String superClass = null; String classType = null; if (node.getImplementsClause() != null) { implementsList = (List) mProductions.removeLast(); } if (node.getExtendsClause() != null) { superClass = (String) mProductions.removeLast(); } classType = (String) mProductions.removeLast(); int modifierCount = node.getModifier().size(); int modifierFlags = processModifiers(node.getModifier()); if (classType.equals("interface")) { modifierFlags |= Modifier.INTERFACE; } mSootClass.setModifiers(modifierFlags); if (superClass != null) { mSootClass.setSuperclass(mResolver.makeClassRef(superClass)); } if (implementsList != null) { Iterator implIt = implementsList.iterator(); while (implIt.hasNext()) { SootClass interfaceClass = mResolver.makeClassRef((String) implIt.next()); mSootClass.addInterface(interfaceClass); } } mProductions.addLast(mSootClass); }
tclass.setSuperclass(Scene.v().getObjectType().getSootClass()); tclass.addInterface(functionalInterfaceToImplement);
public MonitorConverter(Singletons.Global g) { SootClass davaMonitor = new SootClass("soot.dava.toolkits.base.DavaMonitor.DavaMonitor", Modifier.PUBLIC); davaMonitor.setSuperclass(Scene.v().loadClassAndSupport("java.lang.Object")); LinkedList objectSingleton = new LinkedList(); objectSingleton.add(RefType.v("java.lang.Object")); v = Scene.v().makeSootMethod("v", new LinkedList(), RefType.v("soot.dava.toolkits.base.DavaMonitor.DavaMonitor"), Modifier.PUBLIC | Modifier.STATIC); enter = Scene.v().makeSootMethod("enter", objectSingleton, VoidType.v(), Modifier.PUBLIC | Modifier.SYNCHRONIZED); exit = Scene.v().makeSootMethod("exit", objectSingleton, VoidType.v(), Modifier.PUBLIC | Modifier.SYNCHRONIZED); davaMonitor.addMethod(v); davaMonitor.addMethod(enter); davaMonitor.addMethod(exit); Scene.v().addClass(davaMonitor); }
private soot.SootClass getSpecialInterfaceAnonClass(soot.SootClass addToClass) { // check to see if there is already a special anon class for this // interface if ((InitialResolver.v().specialAnonMap() != null) && (InitialResolver.v().specialAnonMap().containsKey(addToClass))) { return InitialResolver.v().specialAnonMap().get(addToClass); } else { String specialClassName = addToClass.getName() + "$" + InitialResolver.v().getNextAnonNum(); // add class to scene and other maps and lists as needed soot.SootClass specialClass = new soot.SootClass(specialClassName); soot.Scene.v().addClass(specialClass); specialClass.setApplicationClass(); specialClass.addTag(new soot.tagkit.SyntheticTag()); specialClass.setSuperclass(soot.Scene.v().getSootClass("java.lang.Object")); Util.addInnerClassTag(addToClass, specialClass.getName(), addToClass.getName(), null, soot.Modifier.STATIC); Util.addInnerClassTag(specialClass, specialClass.getName(), addToClass.getName(), null, soot.Modifier.STATIC); InitialResolver.v().addNameToAST(specialClassName); references.add(RefType.v(specialClassName)); if (InitialResolver.v().specialAnonMap() == null) { InitialResolver.v().setSpecialAnonMap(new HashMap<SootClass, SootClass>()); } InitialResolver.v().specialAnonMap().put(addToClass, specialClass); return specialClass; } }
@Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { name = AsmUtil.toQualifiedName(name); if (!name.equals(klass.getName())) { throw new RuntimeException("Class names not equal! " + name + " != " + klass.getName()); } klass.setModifiers(access & ~Opcodes.ACC_SUPER); if (superName != null) { superName = AsmUtil.toQualifiedName(superName); addDep(RefType.v(superName)); klass.setSuperclass(SootResolver.v().makeClassRef(superName)); } for (String intrf : interfaces) { intrf = AsmUtil.toQualifiedName(intrf); addDep(RefType.v(intrf)); SootClass interfaceClass = SootResolver.v().makeClassRef(intrf); interfaceClass.setModifiers(interfaceClass.getModifiers() | Modifier.INTERFACE); klass.addInterface(interfaceClass); } if (signature != null) { klass.addTag(new SignatureTag(signature)); } }
String superClassName = Util.dottedClassName(superClass); SootClass sootSuperClass = SootResolver.v().makeClassRef(superClassName); sc.setSuperclass(sootSuperClass); deps.typesToHierarchy.add(sootSuperClass.getType());
/** * @ast method * @aspect EmitJimple * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:186 */ public void jimplify1phase2() { SootClass sc = getSootClassDecl(); sc.setResolvingLevel(SootClass.DANGLING); sc.setModifiers(sootTypeModifiers()); sc.setApplicationClass(); SourceFileTag st = new soot.tagkit.SourceFileTag(sourceNameWithoutPath()); st.setAbsolutePath(compilationUnit().pathName()); sc.addTag(st); sc.setSuperclass(typeObject().getSootClassDecl()); for(Iterator iter = superinterfacesIterator(); iter.hasNext(); ) { TypeDecl typeDecl = (TypeDecl)iter.next(); if(typeDecl != typeObject() && !sc.implementsInterface(typeDecl.getSootClassDecl().getName())) sc.addInterface(typeDecl.getSootClassDecl()); } if(isNestedType()) sc.setOuterClass(enclosingType().getSootClassDecl()); sc.setResolvingLevel(SootClass.HIERARCHY); super.jimplify1phase2(); sc.setResolvingLevel(SootClass.SIGNATURES); } /**
/** * @ast method * @aspect EmitJimple * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:163 */ public void jimplify1phase2() { SootClass sc = getSootClassDecl(); sc.setResolvingLevel(SootClass.DANGLING); sc.setModifiers(sootTypeModifiers()); sc.setApplicationClass(); SourceFileTag st = new soot.tagkit.SourceFileTag(sourceNameWithoutPath()); st.setAbsolutePath(compilationUnit().pathName()); sc.addTag(st); if(hasSuperclass()) { sc.setSuperclass(superclass().getSootClassDecl()); } for(Iterator iter = interfacesIterator(); iter.hasNext(); ) { TypeDecl typeDecl = (TypeDecl)iter.next(); if(!sc.implementsInterface(typeDecl.getSootClassDecl().getName())) sc.addInterface(typeDecl.getSootClassDecl()); } if(isNestedType()) sc.setOuterClass(enclosingType().getSootClassDecl()); sc.setResolvingLevel(SootClass.HIERARCHY); super.jimplify1phase2(); sc.setResolvingLevel(SootClass.SIGNATURES); } /**
bclass.setSuperclass(SootResolver.v().makeClassRef(superName));
mediatingClass.setSuperclass(originalSuperclass); sc.setSuperclass(mediatingClass);
sootClass.setSuperclass(superClass); } else { sootClass.setSuperclass(((soot.RefType) Util.getSootType(cDecl.superClass().type())).getSootClass()); if (((polyglot.types.ClassType) cDecl.superClass().type()).isNested()) { polyglot.types.ClassType superType = (polyglot.types.ClassType) cDecl.superClass().type();
sootClass.setSuperclass(soot.Scene.v().getSootClass("java.lang.Object")); } else { sootClass.setSuperclass(typeClass); if (((polyglot.types.ClassType) aNew.objectType().type()).isNested()) { polyglot.types.ClassType superType = (polyglot.types.ClassType) aNew.objectType().type();
if (rt.getSootClass().isPhantom() && !rt.getSootClass().hasSuperclass() && !rt.getSootClass().getName().equals("java.lang.Throwable")) { rt.getSootClass().setSuperclass(Scene.v().getSootClass("java.lang.Throwable"));
/** * Get a method that returns an unknown value of type t. * * @param t * @return */ public SootMethod getHavocMethod(soot.Type t) { if (!Scene.v().containsClass(HavocClassName)) { SootClass sClass = new SootClass(HavocClassName, Modifier.PUBLIC | Modifier.PUBLIC); sClass.setSuperclass(Scene.v().getSootClass("java.lang.Object")); sClass.setResolvingLevel(SootClass.SIGNATURES); Scene.v().addClass(sClass); } SootClass cls = Scene.v().getSootClass(HavocClassName); final String havocMethodName = HavocMethodName + t.toString(); if (!cls.declaresMethodByName(havocMethodName)) { cls.addMethod(new SootMethod(havocMethodName, Arrays.asList(new Type[] {}), t, Modifier.PUBLIC | Modifier.STATIC)); } return cls.getMethodByName("havoc_" + t.toString()); }
bclass.setSuperclass(SootResolver.v().makeClassRef(superName));
sClass.setSuperclass(Scene.v().getSootClass("java.lang.Object"));
/** * return the ApplicationHolder class (created if needed) This is a class with 1 * static field to save the application instance in */ public static SootClass createOrGetApplicationHolder() { SootClass scApplication = Scene.v().getSootClassUnsafe("android.app.Application"); if (scApplication == null || scApplication.resolvingLevel() < SootClass.SIGNATURES) return null; String applicationHolderClassName = "il.ac.tau.MyApplicationHolder"; SootClass scApplicationHolder; if (!Scene.v().containsClass(applicationHolderClassName)) { scApplicationHolder = Scene.v().makeSootClass(applicationHolderClassName, Modifier.PUBLIC); scApplicationHolder.setSuperclass(Scene.v().getSootClass("java.lang.Object")); Scene.v().addClass(scApplicationHolder); scApplicationHolder.addField( Scene.v().makeSootField("application", scApplication.getType(), Modifier.PUBLIC | Modifier.STATIC)); scApplicationHolder.validate(); } else { scApplicationHolder = Scene.v().getSootClassUnsafe(applicationHolderClassName); } return scApplicationHolder; }
if (exceptionClass == null) { exceptionClass = Scene.v().makeSootClass("FLOWDROID_EXCEPTIONS", Modifier.PUBLIC); exceptionClass.setSuperclass(Scene.v().getSootClass("java.lang.Object")); Scene.v().addClass(exceptionClass);
arrayClass.setSuperclass(objReplCls); arrayClass.setSuperclass(objCls);