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); } }
/** * 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)); }
/** * Emits the bytecode for the complete class */ protected void generateByteCode() { generateClassHeader(); // Retrieve information about the source of the class if (sc.hasTag("SourceFileTag") && !Options.v().no_output_source_file_attribute()) { String srcName = ((SourceFileTag) sc.getTag("SourceFileTag")).getSourceFile(); cv.visitSource(srcName, null); // TODO Correct value for the debug // argument } // Retrieve information about outer class if present if (sc.hasOuterClass() || sc.hasTag("EnclosingMethodTag") || sc.hasTag("OuterClassTag")) { generateOuterClassReference(); } // Retrieve information about annotations generateAnnotations(cv, sc); // Retrieve information about attributes generateAttributes(); // Retrieve information about inner classes generateInnerClassReferences(); // Generate fields generateFields(); // Generate methods generateMethods(); cv.visitEnd(); }
public JVirtualInvokeExpr(Value base, SootMethodRef methodRef, List<? extends Value> args) { super(Jimple.v().newLocalBox(base), methodRef, new ValueBox[args.size()]); if (!Options.v().ignore_resolution_errors()) { // Check that the method's class is resolved enough methodRef.declaringClass().checkLevelIgnoreResolving(SootClass.HIERARCHY); // now check if the class is valid if (methodRef.declaringClass().isInterface()) { SootClass sc = methodRef.declaringClass(); String path = sc.hasTag("SourceFileTag") ? ((SourceFileTag) sc.getTag("SourceFileTag")).getAbsolutePath() : "uknown"; throw new RuntimeException("Trying to create virtual invoke expression for interface type (" + methodRef.declaringClass().getName() + " in file " + path + "). Use JInterfaceInvokeExpr instead!"); } } for (int i = 0; i < args.size(); i++) { this.argBoxes[i] = Jimple.v().newImmediateBox(args.get(i)); } }
/** * Emits the bytecode for all references to inner classes if present */ protected void generateInnerClassReferences() { if (sc.hasTag("InnerClassAttribute") && !Options.v().no_output_inner_classes_attribute()) { InnerClassAttribute ica = (InnerClassAttribute) sc.getTag("InnerClassAttribute"); List<InnerClassTag> sortedTags = new ArrayList<InnerClassTag>(ica.getSpecs()); Collections.sort(sortedTags, new SootInnerClassComparator()); for (InnerClassTag ict : sortedTags) { String name = slashify(ict.getInnerClass()); String outerClassName = slashify(ict.getOuterClass()); String innerName = slashify(ict.getShortName()); int access = ict.getAccessFlags(); cv.visitInnerClass(name, outerClassName, innerName, access); } } }
/** * Emits the bytecode for a reference to an outer class if necessary */ protected void generateOuterClassReference() { SootClass outerClass = sc.getOuterClass(); String outerClassName = slashify(outerClass.getName()); String enclosingMethod = null; String enclosingMethodSig = null; if (sc.hasTag("EnclosingMethodTag")) { EnclosingMethodTag emTag = (EnclosingMethodTag) sc.getTag("EnclosingMethodTag"); if (!sc.hasOuterClass()) { outerClassName = slashify(emTag.getEnclosingClass()); } enclosingMethod = emTag.getEnclosingMethod(); enclosingMethodSig = emTag.getEnclosingMethodSig(); } if (!sc.hasOuterClass() && sc.hasTag("OuterClassTag")) { outerClassName = slashify(((OuterClassTag) sc.getTag("OuterClassTag")).getName()); } cv.visitOuterClass(outerClassName, enclosingMethod, enclosingMethodSig); }
if (sc.hasTag("SignatureTag")) { signature = ((SignatureTag) sc.getTag("SignatureTag")).getSignature();
if (c.hasTag("EnclosingMethodTag")) { EnclosingMethodTag eMethTag = (EnclosingMethodTag) c.getTag("EnclosingMethodTag"); Annotation enclosingMethodItem = buildEnclosingMethodTag(eMethTag, skipList);
if (!sc.hasTag("InnerClassTag")) { if (((InnerClassTag) t).getInnerClass().replaceAll("/", ".").equals(sc.toString())) { sc.addTag(t);
if (sootClass.hasTag("SyntheticTag") || Modifier.isSynthetic(sootClass.getModifiers())) { emit(".synthetic\n"); if (sootClass.hasTag("EnclosingMethodTag")) { String encMeth = ".enclosing_method_attr "; EnclosingMethodTag eMethTag = (EnclosingMethodTag) sootClass.getTag("EnclosingMethodTag"); if (sootClass.hasTag("DeprecatedTag")) { emit(".deprecated\n"); if (sootClass.hasTag("SignatureTag")) { String sigAttr = ".signature_attr "; SignatureTag sigTag = (SignatureTag) sootClass.getTag("SignatureTag");
private void addAsClassDefItem(SootClass c) { if (c.hasTag("SourceFileTag")) { SourceFileTag sft = (SourceFileTag) c.getTag("SourceFileTag"); sourceFile = sft.getSourceFile();
if (sootClass.hasTag("SourceFileTag")) { soot.tagkit.SourceFileTag t = (soot.tagkit.SourceFileTag) sootClass.getTag("SourceFileTag");