public static void addInnerClassTag(soot.SootClass sc, String innerName, String outerName, String simpleName, int access) { // maybe need file sep here - may break windows innerName = innerName.replaceAll(".", "/"); if (outerName != null) { outerName = outerName.replaceAll(".", "/"); } sc.addTag(new soot.tagkit.InnerClassTag(innerName, outerName, simpleName, access)); }
@Override public void visitSource(String source, String debug) { if (source != null) { klass.addTag(new SourceFileTag(source)); } }
@Override public void visitInnerClass(String name, String outerName, String innerName, int access) { klass.addTag(new InnerClassTag(name, outerName, innerName, access)); // soot does not resolve all inner classes, e.g., java.util.stream.FindOps$FindSink$... is not resolved String innerClassname = AsmUtil.toQualifiedName(name); deps.add(RefType.v(innerClassname)); }
public void internalTransform(String phaseName, Map<String, String> options) { Iterator<SootClass> it = Scene.v().getApplicationClasses().iterator(); while (it.hasNext()) { ArrayList<InnerClassTag> list = new ArrayList<InnerClassTag>(); SootClass nextSc = it.next(); for (Tag t : nextSc.getTags()) { if (t instanceof InnerClassTag) { list.add((InnerClassTag) t); } } if (!list.isEmpty()) { nextSc.addTag(new InnerClassAttribute(list)); } } } }
private void addSourceFileTag(soot.SootClass sc) { if (fileName == null && zipFileName == null) { return; } soot.tagkit.SourceFileTag tag = null; if (sc.hasTag("SourceFileTag")) { tag = (soot.tagkit.SourceFileTag) sc.getTag("SourceFileTag"); } else { tag = new soot.tagkit.SourceFileTag(); sc.addTag(tag); } // Sets sourceFile only when it hasn't been set before if (tag.getSourceFile() == null) { String name = zipFileName == null ? new File(fileName).getName() : new File(zipFileName).getName(); tag.setSourceFile(name); } }
/** * adds source file tag to each sootclass */ protected static void addSourceFileTag(SootClass sc, String fileName) { soot.tagkit.SourceFileTag tag = null; if (sc.hasTag("SourceFileTag")) { return; // do not add tag if original class already has debug // information } else { tag = new soot.tagkit.SourceFileTag(); sc.addTag(tag); } tag.setSourceFile(fileName); } }
/** * @ast method * @aspect AnnotationsCodegen * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/Jimple1.5Backend/AnnotationsCodegen.jrag:20 */ public void addAttributes() { super.addAttributes(); ArrayList c = new ArrayList(); getModifiers().addRuntimeVisibleAnnotationsAttribute(c); getModifiers().addRuntimeInvisibleAnnotationsAttribute(c); getModifiers().addSourceOnlyAnnotations(c); for (Iterator iter = c.iterator(); iter.hasNext();) { soot.tagkit.Tag tag = (soot.tagkit.Tag) iter.next(); getSootClassDecl().addTag(tag); } }
@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)); }
/** * @ast method * @aspect EmitJimple * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:932 */ public void jimplify2() { super.jimplify2(); if (clinit != null) jimplify2clinit(); for (Iterator iter = nestedTypes().iterator(); iter.hasNext();) { TypeDecl typeDecl = (TypeDecl) iter.next(); typeDecl.jimplify2(); } // add inner class attribute ArrayList tags = new ArrayList(); for (Iterator iter = innerClassesAttributeEntries().iterator(); iter.hasNext();) { TypeDecl type = (TypeDecl) iter.next(); tags.add(new soot.tagkit.InnerClassTag(type.jvmName().replace('.', '/'), type.isMemberType() ? type.enclosingType().jvmName().replace('.', '/') : null, type.isAnonymous() ? null : type.name(), type.sootTypeModifiers())); } if (!tags.isEmpty()) getSootClassDecl().addTag(new soot.tagkit.InnerClassAttribute(tags)); addAttributes(); getSootClassDecl().setResolvingLevel(SootClass.BODIES); }
b.getMethod().getDeclaringClass().addTag(new KeyTag(ColorTag.RED, "Nullness: Null", "NullCheckTag")); b.getMethod().getDeclaringClass().addTag(new KeyTag(ColorTag.GREEN, "Nullness: Not Null", "NullCheckTag")); b.getMethod().getDeclaringClass().addTag(new KeyTag(ColorTag.BLUE, "Nullness: Nullness Unknown", "NullCheckTag"));
/** * adds source file tag to each sootclass */ protected void addSourceFileTag(soot.SootClass sc) { soot.tagkit.SourceFileTag tag = null; if (sc.hasTag("SourceFileTag")) { tag = (soot.tagkit.SourceFileTag) sc.getTag("SourceFileTag"); } else { tag = new soot.tagkit.SourceFileTag(); sc.addTag(tag); } String name = Util.getSourceFileOfClass(sc); if (InitialResolver.v().classToSourceMap() != null) { if (InitialResolver.v().classToSourceMap().containsKey(name)) { name = InitialResolver.v().classToSourceMap().get(name); } } // the pkg is not included in the tag for some unknown reason // I think in this case windows uses the same slash - may cause // windows problems though int slashIndex = name.lastIndexOf("/"); if (slashIndex != -1) { name = name.substring(slashIndex + 1); } tag.setSourceFile(name); // sc.addTag(new soot.tagkit.SourceFileTag(name)); }
b.getMethod().getDeclaringClass().addTag(new KeyTag(255, 0, 0, "Parity: Top", "Parity Analysis")); b.getMethod().getDeclaringClass().addTag(new KeyTag(45, 255, 84, "Parity: Bottom", "Parity Analysis")); b.getMethod().getDeclaringClass().addTag(new KeyTag(255, 248, 35, "Parity: Even", "Parity Analysis")); b.getMethod().getDeclaringClass().addTag(new KeyTag(174, 210, 255, "Parity: Odd", "Parity Analysis"));
@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)); } }
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; } }
sootClass.addTag(t);
/** * @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); } /**
/** * @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); } /**
logger.info("Adding SourceFileTag for class {}", fullyQualifiedName); sourceFileTag = new SourceFileTag(); applicationClass.addTag(sourceFileTag);