Tabnine Logo
SootClass
Code IndexAdd Tabnine to your IDE (free)

How to use
SootClass
in
soot

Best Java code snippets using soot.SootClass (Showing top 20 results out of 315)

origin: Sable/soot

private static Collection<AncestryTreeNode> buildAncestryTree(RefType root) {
 if (root.getSootClass().isPhantom()) {
  return Collections.emptyList();
 }
 LinkedList<AncestryTreeNode> leafs = new LinkedList<AncestryTreeNode>();
 leafs.add(new AncestryTreeNode(null, root));
 LinkedList<AncestryTreeNode> r = new LinkedList<AncestryTreeNode>();
 final RefType objectType = RefType.v("java.lang.Object");
 while (!leafs.isEmpty()) {
  AncestryTreeNode node = leafs.remove();
  if (TypeResolver.typesEqual(node.type, objectType)) {
   r.add(node);
  } else {
   SootClass sc = node.type.getSootClass();
   for (SootClass i : sc.getInterfaces()) {
    leafs.add(new AncestryTreeNode(node, (i).getType()));
   }
   // The superclass of all interfaces is Object
   // -- try to discard phantom interfaces.
   if ((!sc.isInterface() || sc.getInterfaceCount() == 0) && !sc.isPhantom()) {
    leafs.add(new AncestryTreeNode(node, sc.getSuperclass().getType()));
   }
  }
 }
 return r;
}
origin: Sable/soot

public static void retrieveAllNames() {
 if (namesHaveBeenRetrieved) {
  return;
 }
 // iterate through application classes, rename fields with junk
 for (SootClass c : soot.Scene.v().getApplicationClasses()) {
  nameList.add(c.getName());
  for (SootMethod m : c.getMethods()) {
   nameList.add(m.getName());
  }
  for (SootField m : c.getFields()) {
   nameList.add(m.getName());
  }
 }
 namesHaveBeenRetrieved = true;
}
origin: Sable/soot

private void loadNecessaryClass(String name) {
 SootClass c;
 c = loadClassAndSupport(name);
 c.setApplicationClass();
}
origin: Sable/soot

/**
 * WARNING: interfaces are subclasses of the java.lang.Object class! Returns the superclass of this class. (see
 * hasSuperclass())
 */
public SootClass getSuperclass() {
 checkLevel(HIERARCHY);
 if (superClass == null && !isPhantom()) {
  throw new RuntimeException("no superclass for " + getName());
 } else {
  return superClass;
 }
}
origin: Sable/soot

private boolean isCallClassSubClass(SootClass call, SootClass check) {
 if (!call.hasSuperclass()) {
  return false;
 }
 if (call.getSuperclass().equals(check)) {
  return true;
 }
 return false;
}
origin: Sable/soot

public static List<SootField> getAllFields(SootClass sc) {
 // Get list of reachable methods declared in this class
 // Also get list of fields declared in this class
 List<SootField> allFields = new ArrayList<SootField>();
 for (SootField field : sc.getFields()) {
  allFields.add(field);
 }
 // Add reachable methods and fields declared in superclasses
 SootClass superclass = sc;
 if (superclass.hasSuperclass()) {
  superclass = superclass.getSuperclass();
 }
 while (superclass.hasSuperclass()) // we don't want to process Object
 {
  for (SootField scField : superclass.getFields()) {
   allFields.add(scField);
  }
  superclass = superclass.getSuperclass();
 }
 return allFields;
}
origin: Sable/soot

String enclosingClassname = enclosingClass.getName();
String enclosingClassnamePrefix = null;
if (enclosingClassname == null || enclosingClassname.equals("")) {
SootClass tclass = new SootClass(className);
tclass.setModifiers(Modifier.PUBLIC | Modifier.FINAL);
tclass.setSuperclass(Scene.v().getObjectType().getSootClass());
tclass.addInterface(functionalInterfaceToImplement);
 tclass.addInterface(RefType.v("java.io.Serializable").getSootClass());
 tclass.addInterface(((RefType) AsmUtil.toBaseType(markerInterfaces.get(i).getValue())).getSootClass());
 SootField f = new SootField("cap" + i, capTypes.get(i), 0);
 capFields.add(f);
 tclass.addField(f);
 if (implMethod.getMethodRef().declaringClass().getName().equals(enclosingClassname)) {
  SootMethod method
    = implMethod.getMethodRef().declaringClass().getMethod(implMethod.getMethodRef().getSubSignature());
  int modifiers = method.getModifiers() & ~Modifier.PRIVATE;
  modifiers = modifiers | Modifier.PUBLIC;
SootMethod tboot = new SootMethod("bootstrap$", capTypes, functionalInterfaceToImplement.getType(),
  Modifier.PUBLIC | Modifier.STATIC);
tclass.addMethod(tboot);
tboot.setSource(ms);
tclass.addMethod(tctor);
origin: Sable/soot

Map<String, SootMethod> methodsToAdd = new HashMap<>();
SootClass sc = it.next();
SootClass originalSuperclass = sc.getSuperclass();
 out.println("Processing " + sc.getName() + " with super " + originalSuperclass.getName());
Iterator<SootMethod> methodIterator = sc.methodIterator();
while (methodIterator.hasNext()) {
 SootMethod method = methodIterator.next();
 final String fullName = ClassRenamer.v().getOrAddNewName(ClassRenamer.getPackageName(sc.getName()), null);
 SootClass mediatingClass = new SootClass(fullName, sc.getModifiers() & (~Modifier.FINAL));
 Main.IntermediateAppClasses.add(mediatingClass);
 mediatingClass.setSuperclass(originalSuperclass);
 mediatingClass.setApplicationClass();
 mediatingClass.setInScene(true);
 ThisRef thisRef = new ThisRef(mediatingClass.getType());
   mediatingClass.addMethod(newMethod);
   mediatingClass.addMethod(newMethod);
 sc.setSuperclass(mediatingClass);
     SpecialInvokeExpr sie = (SpecialInvokeExpr) v;
     SootMethodRef smr = sie.getMethodRef();
origin: Sable/soot

/**
 * @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);
}
/**
origin: Sable/soot

private void addAsClassDefItem(SootClass c) {
 if (c.hasTag("SourceFileTag")) {
  SourceFileTag sft = (SourceFileTag) c.getTag("SourceFileTag");
  sourceFile = sft.getSourceFile();
 String classType = SootToDexUtils.getDexTypeDescriptor(c.getType());
 int accessFlags = c.getModifiers();
 String superClass = c.hasSuperclass() ? SootToDexUtils.getDexTypeDescriptor(c.getSuperclass().getType()) : null;
 if (!c.getInterfaces().isEmpty()) {
  interfaces = new ArrayList<String>();
  for (SootClass ifc : c.getInterfaces()) {
   interfaces.add(SootToDexUtils.getDexTypeDescriptor(ifc.getType()));
 if (!c.getFields().isEmpty()) {
  fields = new ArrayList<Field>();
  for (SootField f : c.getFields()) {
origin: Sable/soot

/**
 * Returns a list of <strong>direct</strong> superclasses of passed class in reverse order, starting with its parent.
 *
 * @param sootClass
 *          the <strong>class</strong> of which superclasses will be taken. Must not be {@code null} or interface
 * @return list of superclasses
 * @throws IllegalArgumentException
 *           when passed class is an interface
 * @throws NullPointerException
 *           when passed argument is {@code null}
 */
public List<SootClass> getSuperclassesOf(SootClass sootClass) {
 sootClass.checkLevel(SootClass.HIERARCHY);
 if (sootClass.isInterface()) {
  throw new IllegalArgumentException(sootClass.getName() + " is an interface, but class is expected");
 }
 checkState();
 final List<SootClass> superclasses = new ArrayList<>();
 SootClass current = sootClass;
 while (current.hasSuperclass()) {
  superclasses.add(current.getSuperclass());
  current = current.getSuperclass();
 }
 return Collections.unmodifiableList(superclasses);
}
origin: Sable/soot

private Set<SootClass> getParentsOfIncluding(Collection<SootClass> classes) {
 final Set<SootClass> parents = new HashSet<>(classes);
 for (SootClass clazz : classes) {
  // add implementing interfaces
  parents.addAll(clazz.getInterfaces());
  // add extending class if any
  if (!clazz.isInterface() && clazz.hasSuperclass()) {
   parents.add(clazz.getSuperclass());
  }
  // and superclasses (superinterfaces) of passed applicationClass
  parents.addAll(clazz.isInterface() ? Scene.v().getActiveHierarchy().getSuperinterfacesOfIncluding(clazz)
    : Scene.v().getActiveHierarchy().getSuperclassesOfIncluding(clazz));
 }
 return parents;
}
origin: Sable/soot

SootClass sc = worklist[i].pop();
if (resolveEverything()) { // Whole program mode
 boolean onlySignatures = sc.isPhantom() || (Options.v().no_bodies_for_excluded() && Scene.v().isExcluded(sc)
   && !Scene.v().getBasicClasses().contains(sc.getName()));
 if (onlySignatures) {
  bringToSignatures(sc);
  sc.setPhantomClass();
  for (SootMethod m : sc.getMethods()) {
   m.setPhantom(true);
  for (SootField f : sc.getFields()) {
   f.setPhantom(true);
origin: Sable/soot

if (s.isPhantom()) {
 continue;
 s.setApplicationClass();
if (Options.v().classes().contains(s.getName())) {
 s.setApplicationClass();
 continue;
if (s.isApplicationClass() && isExcluded(s)) {
 s.setLibraryClass();
 s.setApplicationClass();
if (s.isApplicationClass()) {
 loadClassAndSupport(s.getName());
origin: Sable/soot

 throw new RuntimeException("Oops, forgot to load " + type);
if (sClass.isPhantomClass()) {
 throw new RuntimeException("Jimplification requires " + sClass + ", but it is a phantom ref.");
SootClass superclass = sClass.getSuperclassUnsafe();
if (superclass != null && !sClass.getName().equals("java.lang.Object")) {
 TypeNode parent = hierarchy.typeNode(RefType.v(sClass.getSuperclass().getName()));
 plist.add(parent);
 parentClass = parent;
for (Iterator<SootClass> i = sClass.getInterfaces().iterator(); i.hasNext();) {
 TypeNode parent = hierarchy.typeNode(RefType.v((i.next()).getName()));
 plist.add(parent);
origin: Sable/soot

private Set<SootClass> getChildrenOfIncluding(Collection<SootClass> classes) {
 return Stream
   .concat(classes.stream().filter(c -> !c.getName().equals("java.lang.Object"))
     .map(c -> c.isInterface() ? Scene.v().getActiveHierarchy().getImplementersOf(c)
       : Scene.v().getActiveHierarchy().getSubclassesOf(c))
     .flatMap(Collection::stream), classes.stream())
   .collect(toSet());
}
origin: Sable/soot

while (selectedClass != null) {
 if (trace != null) {
  trace.append("Looking in ").append(selectedClass).append(" which has methods ").append(selectedClass.getMethods())
    .append("\n");
 final SootMethod method = selectedClass.getMethodUnsafe(name, parameterTypes, returnType);
 if (method != null) {
  checkStatic(method);
 if (Scene.v().allowsPhantomRefs() && selectedClass.isPhantom()) {
  SootMethod phantomMethod
    = Scene.v().makeSootMethod(name, parameterTypes, returnType, isStatic() ? Modifier.STATIC : 0);
  phantomMethod.setPhantom(true);
  phantomMethod = selectedClass.getOrAddMethod(phantomMethod);
  checkStatic(phantomMethod);
  return phantomMethod;
 selectedClass = selectedClass.getSuperclassUnsafe();
 final Queue<SootClass> queue = new ArrayDeque<>(selectedClass.getInterfaces());
 while (!queue.isEmpty()) {
  final SootClass iface = queue.poll();
  if (trace != null) {
   trace.append("Looking in ").append(iface).append(" which has methods ").append(iface.getMethods()).append("\n");
  final SootMethod method = iface.getMethodUnsafe(name, parameterTypes, returnType);
  if (method != null) {
   checkStatic(method);
origin: Sable/soot

int classModifiers = sc.getModifiers();
int modifier = getModifiers(classModifiers, sc);
String className = slashify(sc.getName());
if (sc.hasTag("SignatureTag")) {
 signature = ((SignatureTag) sc.getTag("SignatureTag")).getSignature();
SootClass csuperClass = sc.getSuperclassUnsafe();
if (csuperClass != null) {
 superClass = slashify(csuperClass.getName());
String[] interfaces = new String[sc.getInterfaceCount()];
Iterator<SootClass> implementedInterfaces = sc.getInterfaces().iterator();
int i = 0;
while (implementedInterfaces.hasNext()) {
 SootClass interf = implementedInterfaces.next();
 interfaces[i] = slashify(interf.getName());
 ++i;
origin: Sable/soot

 private Optional<SootMethod> findAccessibleInSuperClassesBySubSig(SootClass base, String subSig) {
  Hierarchy hierarchy = Scene.v().getActiveHierarchy();
  for (SootClass superClass : hierarchy.getSuperclassesOfIncluding(base.getSuperclass())) {
   if (superClass.isLibraryClass() && superClass.declaresMethod(subSig)) {
    SootMethod method = superClass.getMethod(subSig);
    if (hierarchy.isVisible(base, method)) {
     return Optional.of(method);
    }
   }
  }
  return Optional.empty();
 }
}
origin: Sable/soot

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;
 }
}
sootSootClass

Javadoc

Soot representation of a Java class. They are usually created by a Scene, but can also be constructed manually through the given constructors.

Most used methods

  • isInterface
    Convenience method; returns true if this class is an interface.
  • getMethods
  • getName
    Returns the name of this class.
  • setApplicationClass
    Makes this class an application class.
  • getFields
    Returns a backed Chain of fields.
  • getInterfaces
    Returns a backed Chain of the interfaces that are directly implemented by this class. (see getInterf
  • getSuperclass
    WARNING: interfaces are subclasses of the java.lang.Object class! Returns the superclass of this cla
  • hasSuperclass
    WARNING: interfaces are subclasses of the java.lang.Object class! Does this class have a superclass?
  • resolvingLevel
  • addMethod
    Adds the given method to this class.
  • declaresMethod
    Does this class declare a method with the given subsignature?
  • getMethod
  • declaresMethod,
  • getMethod,
  • getType,
  • isApplicationClass,
  • isLibraryClass,
  • addField,
  • isAbstract,
  • isPhantom,
  • <init>,
  • declaresField

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • requestLocationUpdates (LocationManager)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Collectors (java.util.stream)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now