Class JavaSootClass

java.lang.Object
sootup.java.core.JavaSootClass
All Implemented Interfaces:
HasPosition, SootClass, HasAnnotation
Direct Known Subclasses:
JavaAnnotationSootClass

public class JavaSootClass extends Object implements SootClass, HasAnnotation
  • Constructor Details

  • Method Details

    • getMethod

      public @NonNull Optional<JavaSootMethod> getMethod(@NonNull MethodSubSignature subSignature)
      Description copied from interface: SootClass
      Attempts to retrieve the method with the given subSignature. This method may throw an AmbiguousStateException if there are more than one method with the given subSignature. If no method with the given is found, null is returned.
      Specified by:
      getMethod in interface SootClass
    • getField

      public @NonNull Optional<JavaSootField> getField(@NonNull FieldSubSignature subSignature)
      Description copied from interface: SootClass
      Attemtps to retrieve the field with the given FieldSubSignature.
      Specified by:
      getField in interface SootClass
    • getField

      public @NonNull Optional<JavaSootField> getField(@NonNull String name)
      Description copied from interface: SootClass
      Returns the field of this class with the given name. Throws a ResolveException if there is more than one field with the given name. Returns null if no field with the given name exists.
      Specified by:
      getField in interface SootClass
    • getMethod

      public @NonNull Optional<JavaSootMethod> getMethod(@NonNull String name, @NonNull Iterable<? extends Type> parameterTypes)
      Description copied from interface: SootClass
      Attempts to retrieve the method with the given name and parameters. This method may throw an ResolveException if there is more than one method with the given name and parameter.
      Specified by:
      getMethod in interface SootClass
    • getMethodsByName

      public @NonNull Set<JavaSootMethod> getMethodsByName(@NonNull String name)
      Description copied from interface: SootClass
      Attempts to retrieve the method with the given name. This method will return an empty Set if there is no method with the given name.
      Specified by:
      getMethodsByName in interface SootClass
      Parameters:
      name - the name of the method
      Returns:
      a set of methods that have the given name
    • getMethods

      public @NonNull Set<JavaSootMethod> getMethods()
      Gets the methods of this SootClass in an immutable set.
      Specified by:
      getMethods in interface SootClass
    • getFields

      public @NonNull Set<JavaSootField> getFields()
      Gets the fields of this SootClass in an immutable set.
      Specified by:
      getFields in interface SootClass
    • getModifiers

      public @NonNull Set<ClassModifier> getModifiers()
      Returns the modifiers of this class in an immutable set.
      Specified by:
      getModifiers in interface SootClass
    • getInterfaces

      public Set<? extends ClassType> getInterfaces()
      Returns a backed Chain of the interfaces that are directly implemented by this class. Note that direct implementation corresponds to an "implements" keyword in the Java class file and that this class may still be implementing additional interfaces in the usual sense by being a subclass of a class which directly implements some interfaces.
      Specified by:
      getInterfaces in interface SootClass
    • implementsInterface

      public boolean implementsInterface(@NonNull ClassType classSignature)
      Does this class directly implement the given interface? (see getInterfaceCount())
    • hasSuperclass

      public boolean hasSuperclass()
      WARNING: interfaces are subclasses of the java.lang.Object class! Does this class have a superclass? False implies that this is the java.lang.Object class. Note that interfaces are subclasses of the java.lang.Object class.
      Specified by:
      hasSuperclass in interface SootClass
    • getSuperclass

      public Optional<JavaClassType> getSuperclass()
      WARNING: interfaces in Java are subclasses of the java.lang.Object class! Returns the superclass of this class. (see hasSuperclass())
      Specified by:
      getSuperclass in interface SootClass
    • hasOuterClass

      public boolean hasOuterClass()
      Specified by:
      hasOuterClass in interface SootClass
    • getOuterClass

      public @NonNull Optional<? extends ClassType> getOuterClass()
      This method returns the outer class.
      Specified by:
      getOuterClass in interface SootClass
    • isInnerClass

      public boolean isInnerClass()
      Specified by:
      isInnerClass in interface SootClass
    • getType

      public ClassType getType()
      Returns the ClassSignature of this class.
      Specified by:
      getType in interface SootClass
    • isInterface

      public boolean isInterface()
      Convenience method; returns true if this class is an interface.
      Specified by:
      isInterface in interface SootClass
    • isEnum

      public boolean isEnum()
      Convenience method; returns true if this class is an enumeration.
      Specified by:
      isEnum in interface SootClass
    • isSuper

      public boolean isSuper()
      Convenience method; returns true if this class is synchronized.
      Specified by:
      isSuper in interface SootClass
    • isConcrete

      public boolean isConcrete()
      Returns true if this class is not an interface and not abstract.
      Specified by:
      isConcrete in interface SootClass
    • isPublic

      public boolean isPublic()
      Convenience method; returns true if this class is public.
      Specified by:
      isPublic in interface SootClass
    • toString

      public @NonNull String toString()
      Returns the name of this class.
      Overrides:
      toString in class Object
    • print

      public @NonNull String print()
      Returns the serialized Jimple of this SootClass as String
      Specified by:
      print in interface SootClass
    • isApplicationClass

      public boolean isApplicationClass()
      Returns true if this class is an application class.
      Specified by:
      isApplicationClass in interface SootClass
    • isLibraryClass

      public boolean isLibraryClass()
      Returns true if this class is a library class.
      Specified by:
      isLibraryClass in interface SootClass
    • isPrivate

      public boolean isPrivate()
      Convenience method returning true if this class is private.
      Specified by:
      isPrivate in interface SootClass
    • isProtected

      public boolean isProtected()
      Convenience method returning true if this class is protected.
      Specified by:
      isProtected in interface SootClass
    • isAbstract

      public boolean isAbstract()
      Convenience method returning true if this class is abstract.
      Specified by:
      isAbstract in interface SootClass
    • isFinal

      public boolean isFinal()
      Convenience method returning true if this class is final.
      Specified by:
      isFinal in interface SootClass
    • isStatic

      public boolean isStatic()
      Convenience method returning true if this class is static.
      Specified by:
      isStatic in interface SootClass
    • isAnnotation

      public boolean isAnnotation()
      Specified by:
      isAnnotation in interface SootClass
    • getPosition

      public @NonNull Position getPosition()
      Description copied from interface: HasPosition
      Line and column information of the corresponding code object that this represents.
      Specified by:
      getPosition in interface HasPosition
      Specified by:
      getPosition in interface SootClass
      Returns:
      a Position containing position information.
    • getClassSource

      public @NonNull SootClassSource getClassSource()
      Specified by:
      getClassSource in interface SootClass
    • getName

      public @NonNull String getName()
      Specified by:
      getName in interface SootClass
    • withClassSource

      public @NonNull JavaSootClass withClassSource(@NonNull SootClassSource classSource)
    • withSourceType

      public @NonNull JavaSootClass withSourceType(@NonNull SourceType sourceType)
    • withMethods

      public @NonNull JavaSootClass withMethods(@NonNull Collection<JavaSootMethod> methods)
    • withReplacedField

      public @NonNull JavaSootClass withReplacedField(@NonNull JavaSootField toReplace, @NonNull JavaSootField replacement)
    • withFields

      public @NonNull JavaSootClass withFields(@NonNull Collection<JavaSootField> fields)
    • withModifiers

      public @NonNull JavaSootClass withModifiers(@NonNull Set<ClassModifier> modifiers)
    • withReplacedMethod

      public @NonNull JavaSootClass withReplacedMethod(@NonNull JavaSootMethod toReplace, @NonNull JavaSootMethod replacement)
    • withSuperclass

      public @NonNull JavaSootClass withSuperclass(@NonNull Optional<JavaClassType> superclass)
    • withOuterClass

      public @NonNull JavaSootClass withOuterClass(@NonNull Optional<JavaClassType> outerClass)
    • withPosition

      public @NonNull JavaSootClass withPosition(@Nullable Position position)
    • getAnnotations

      public Iterable<AnnotationUsage> getAnnotations()
      Get all annotations that are directly attached to this class.

      This includes "visible" and "invisible" annotations. Note that inherited annotations are not part of this iterable.

      Specified by:
      getAnnotations in interface HasAnnotation