/** * Convenience method returning true if this class is abstract. */ public boolean isAbstract() { return Modifier.isAbstract(this.getModifiers()); }
/** * Convenience method returning true if this class is static. */ public boolean isStatic() { return Modifier.isStatic(this.getModifiers()); }
/** * Convenience method returning true if this class is protected. */ public boolean isProtected() { return Modifier.isProtected(this.getModifiers()); }
/** * Convenience method returning true if this class is final. */ public boolean isFinal() { return Modifier.isFinal(this.getModifiers()); }
/** * Convenience method returning true if this class is private. */ public boolean isPrivate() { return Modifier.isPrivate(this.getModifiers()); }
/** Convenience method; returns true if this class is public. */ public boolean isPublic() { return Modifier.isPublic(this.getModifiers()); }
/** Convenience method; returns true if this class is an interface. */ public boolean isInterface() { checkLevel(HIERARCHY); return Modifier.isInterface(this.getModifiers()); }
/** Convenience method; returns true if this class is an enumeration. */ public boolean isEnum() { checkLevel(HIERARCHY); return Modifier.isEnum(this.getModifiers()); }
/** Convenience method; returns true if this class is synchronized. */ public boolean isSynchronized() { checkLevel(HIERARCHY); return Modifier.isSynchronized(this.getModifiers()); }
/** * 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; } }
/** 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; }
/** * Given an abstract dispatch to an object of type c and a method m, gives a list of possible receiver methods. */ public List<SootMethod> resolveAbstractDispatch(SootClass c, SootMethod m) { c.checkLevel(SootClass.HIERARCHY); m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); checkState(); Set<SootMethod> s = new ArraySet<SootMethod>(); Collection<SootClass> classesIt; if (c.isInterface()) { Set<SootClass> classes = new HashSet<SootClass>(); for (SootClass sootClass : getImplementersOf(c)) { classes.addAll(getSubclassesOfIncluding(sootClass)); } classesIt = classes; } else { classesIt = getSubclassesOfIncluding(c); } for (SootClass cl : classesIt) { if (!Modifier.isAbstract(cl.getModifiers())) { s.add(resolveConcreteDispatch(cl, m)); } } return Collections.unmodifiableList(new ArrayList<SootMethod>(s)); }
private void handleInnerClassTags(polyglot.ast.ClassBody classBody) { // if this class is an inner class add self if ((InitialResolver.v().getInnerClassInfoMap() != null) && (InitialResolver.v().getInnerClassInfoMap().containsKey(sootClass))) { // hasTag("OuterClassTag")){ InnerClassInfo tag = InitialResolver.v().getInnerClassInfoMap().get(sootClass); Util.addInnerClassTag(sootClass, sootClass.getName(), tag.getInnerType() == InnerClassInfo.ANON ? null : tag.getOuterClass().getName(), tag.getInnerType() == InnerClassInfo.ANON ? null : tag.getSimpleName(), soot.Modifier.isInterface(tag.getOuterClass().getModifiers()) ? soot.Modifier.STATIC | soot.Modifier.PUBLIC : sootClass.getModifiers()); // if this class is an inner class and enclosing class is also // an inner class add enclsing class SootClass outerClass = tag.getOuterClass(); while (InitialResolver.v().getInnerClassInfoMap().containsKey(outerClass)) { InnerClassInfo tag2 = InitialResolver.v().getInnerClassInfoMap().get(outerClass); Util.addInnerClassTag(sootClass, outerClass.getName(), tag2.getInnerType() == InnerClassInfo.ANON ? null : tag2.getOuterClass().getName(), tag2.getInnerType() == InnerClassInfo.ANON ? null : tag2.getSimpleName(), tag2.getInnerType() == InnerClassInfo.ANON && soot.Modifier.isInterface(tag2.getOuterClass().getModifiers()) ? soot.Modifier.STATIC | soot.Modifier.PUBLIC : outerClass.getModifiers()); outerClass = tag2.getOuterClass(); } } }
minVersion = Options.java_version_1_5; if (Modifier.isAnnotation(sc.getModifiers())) {
int classModifiers = sc.getModifiers(); int modifier = getModifiers(classModifiers, sc);
StringTokenizer st = new StringTokenizer(Modifier.toString(cl.getModifiers())); while (st.hasMoreTokens()) { xmlTempNode.addChild("modifier", new String[] { "name" }, new String[] { st.nextToken() + "" });
@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)); } }
int accessFlags = c.getModifiers(); String superClass = c.hasSuperclass() ? SootToDexUtils.getDexTypeDescriptor(c.getSuperclass().getType()) : null;
} else if (soot.Modifier.isInterface(receiverTypeClass.getModifiers()) && call.methodInstance().flags().isAbstract()) { invoke = soot.jimple.Jimple.v().newInterfaceInvokeExpr(baseLocal, methToCall, params); } else {
} else if (soot.Modifier.isInterface(receiverTypeClass.getModifiers()) && methodInstance.flags().isAbstract()) {