protected void writeMemberClasses(SootClass c, Set<String> skipList, Set<Annotation> annotations) { // Write the MemberClasses tag InnerClassAttribute icTag = (InnerClassAttribute) c.getTag("InnerClassAttribute"); if (icTag != null) { List<Annotation> memberClassesItem = buildMemberClassesAttribute(c, icTag, skipList); if (memberClassesItem != null) { annotations.addAll(memberClassesItem); } } }
EnclosingMethodTag eMethTag = (EnclosingMethodTag) c.getTag("EnclosingMethodTag"); Annotation enclosingMethodItem = buildEnclosingMethodTag(eMethTag, skipList); if (enclosingMethodItem != null) { InnerClassAttribute icTag = (InnerClassAttribute) c.getOuterClass().getTag("InnerClassAttribute"); if (icTag != null) { List<Annotation> innerClassItem = buildInnerClassAttribute(c, icTag, skipList);
InnerClassAttribute ica = (InnerClassAttribute) sc.getTag("InnerClassAttribute"); if (ica != null) { Iterator<InnerClassTag> innerTagIt = ica.getSpecs().iterator(); InnerClassAttribute icat = (InnerClassAttribute) osc.getTag("InnerClassAttribute"); if (icat == null) { icat = new InnerClassAttribute();
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); } }
if ((sootClass.getTag("SourceFileTag") != null) && (!Options.v().no_output_source_file_attribute())) { String srcName = ((SourceFileTag) sootClass.getTag("SourceFileTag")).getSourceFile(); InnerClassAttribute ica = (InnerClassAttribute) sootClass.getTag("InnerClassAttribute"); if (ica != null && ica.getSpecs().size() > 0) { if (!Options.v().no_output_inner_classes_attribute()) { emit(".inner_class_attr "); for (InnerClassTag ict : ((InnerClassAttribute) sootClass.getTag("InnerClassAttribute")).getSpecs()) { EnclosingMethodTag eMethTag = (EnclosingMethodTag) sootClass.getTag("EnclosingMethodTag"); encMeth += "\"" + eMethTag.getEnclosingClass() + "\" "; encMeth += "\"" + eMethTag.getEnclosingMethod() + "\" "; SignatureTag sigTag = (SignatureTag) sootClass.getTag("SignatureTag"); sigAttr += "\"" + sigTag.getSignature() + "\"\n"; emit(sigAttr);
/** * 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)); }
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); } } }
if (((SignatureTag) sc.getTag("SignatureTag")).getSignature().contains("<")) { minVersion = Options.java_version_1_5;
/** * 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); }
signature = ((SignatureTag) sc.getTag("SignatureTag")).getSignature();
if (ica == null) { ica = (InnerClassAttribute) clazz.getTag("InnerClassAttribute");
SourceFileTag sft = (SourceFileTag) c.getTag("SourceFileTag"); sourceFile = sft.getSourceFile();
soot.tagkit.SourceFileTag t = (soot.tagkit.SourceFileTag) sootClass.getTag("SourceFileTag");
SourceFileTag sourceFileTag = (SourceFileTag) applicationClass.getTag(SourceFileTag.NAME); if (sourceFileTag == null) { logger.info("Adding SourceFileTag for class {}", fullyQualifiedName);
/** * 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(); }