/** * Modifies code so that an access to <code>target</code> is legal from code in <code>container</code>. */ public static boolean ensureAccess(SootMethod container, SootClass target, String options) { boolean accessors = options.equals("accessors"); boolean allowChanges = !(options.equals("none")); boolean safeChangesOnly = !(options.equals("unsafe")); if (isAccessLegal(container, target)) { return true; } if (!allowChanges && !accessors) { return false; } if (safeChangesOnly && !accessors) { throw new RuntimeException("Not implemented yet!"); } if (accessors) { return false; } if (target.isApplicationClass()) { target.setModifiers(target.getModifiers() | Modifier.PUBLIC); return true; } else { return false; } }
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); }
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); }
/** Converts a given string class name into a SootClass. * * @param name The dex string representation of the class * @param kind The MethodHandle.Kind of the MethodHandle this class is coming from * @return */ protected SootClass convertClassName(String name, Kind kind) { if (name.startsWith("[")) { name = "java.lang.Object"; } else { name = dottedClassName(name); } SootClass sc = SootResolver.v().makeClassRef(name); if (kind == Kind.REF_INVOKE_INTERFACE && sc.isPhantom()) { sc.setModifiers(sc.getModifiers() | Modifier.INTERFACE); } return sc; }
/** * @apilevel internal */ private SootClass sootClass_compute() { if(options().verbose()) System.out.println("Creating from source " + jvmName()); SootClass sc = SootResolver.v().makeClassRef(jvmName()); sc.setModifiers(sootTypeModifiers()); // turn it into an interface return sc; } /**
tclass.setModifiers(Modifier.PUBLIC | Modifier.FINAL); tclass.setSuperclass(Scene.v().getObjectType().getSootClass()); tclass.addInterface(functionalInterfaceToImplement);
@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)); } }
sc.setModifiers(accessFlags); interfaceClass.setModifiers(interfaceClass.getModifiers() | Modifier.INTERFACE); sc.addInterface(interfaceClass); deps.typesToHierarchy.add(interfaceClass.getType());
/** * adds modifiers */ private void addModifiers(polyglot.types.Flags flags, polyglot.ast.ClassDecl cDecl) { int modifiers = 0; if (cDecl.type().isNested()) { if (flags.isPublic() || flags.isProtected() || flags.isPrivate()) { modifiers = soot.Modifier.PUBLIC; } if (flags.isInterface()) { modifiers = modifiers | soot.Modifier.INTERFACE; } if (flags.isAbstract()) { modifiers = modifiers | soot.Modifier.ABSTRACT; } // if inner classes are declared in an interface they need to be // given public access but I have no idea why // if inner classes are declared in an interface the are // implicitly static and public (jls9.5) if (cDecl.type().outer().flags().isInterface()) { modifiers = modifiers | soot.Modifier.PUBLIC; } } else { modifiers = getModifiers(flags); } sootClass.setModifiers(modifiers); }
/** * @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); } /**
bclass.setModifiers(coffiClass.access_flags & (~0x0020)); interfaceClass.setModifiers(interfaceClass.getModifiers() | Modifier.INTERFACE); bclass.addInterface(interfaceClass);
/** * @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.setModifiers(coffiClass.access_flags & (~0x0020));
bclass.setModifiers(coffiClass.access_flags & (~0x0020));