Class JavaView

java.lang.Object
sootup.core.views.AbstractView
sootup.java.core.views.JavaView
All Implemented Interfaces:
View
Direct Known Subclasses:
JavaEagerView, JavaModuleView, MutableJavaView

public class JavaView extends AbstractView
The Class JavaView manages the Java classes of the application being analyzed. This view cannot be altered after its creation.
Author:
Linghui Luo created on 31.07.2018, Jan Martin Persch
  • Field Details

    • identifierFactory

      protected final @NonNull JavaIdentifierFactory identifierFactory
    • inputLocations

      protected final @NonNull List<AnalysisInputLocation> inputLocations
    • cache

      protected final @NonNull ClassCache cache
    • loadingStrategy

      protected final @NonNull LoadingStrategy loadingStrategy
    • isFullyResolved

      protected volatile boolean isFullyResolved
  • Constructor Details

  • Method Details

    • getClasses

      public @NonNull Stream<JavaSootClass> getClasses()
      Resolves all classes that are part of the view and stores them in the cache.
    • getClass

      public @NonNull Optional<JavaSootClass> getClass(@NonNull ClassType type)
      Resolves the class matching the provided ClassType.
      Returns:
      A class with given signature.
    • forgetAbsence

      protected void forgetAbsence(@NonNull ClassType type)
      Forgets that type was previously resolved as absent, so that the next getClass(ClassType) queries the input locations again. Subclasses that make a class available after construction should call this. Delegates to the active LoadingStrategy; a no-op under the eager strategy, which tracks no absence state to forget - by design, not a bug, since a class absent after an eager load can never become present.

      It is not load-bearing for MutableJavaView as currently written: getClass(ClassType) consults cache before the loading strategy, and addClass populates that cache, so a stale absence record is shadowed anyway. It guards the cases where that no longer holds - if the two checks are ever reordered, or if a mutating view is given an evicting cache such as LRUCache, where an added class can disappear from the cache again and let the stale record surface.

    • getMethod

      public @NonNull Optional<JavaSootMethod> getMethod(@NonNull MethodSignature signature)
      Description copied from class: AbstractView
      resolve and check for accessibility of the class from a given package * TODO: incorporate AccessUtil @NonNull public synchronized Optional<T> getClass( @NonNull PackageName entryPackage, @NonNull ClassType type) { Optional<T> aClass = getClass(type); if (aClass.isPresent() && AccessUtil.isAccessible(entryPackage, aClass.get()) ) { return Optional.empty(); } return aClass; }
      Specified by:
      getMethod in interface View
      Overrides:
      getMethod in class AbstractView
    • getField

      public @NonNull Optional<JavaSootField> getField(@NonNull FieldSignature signature)
      Specified by:
      getField in interface View
      Overrides:
      getField in class AbstractView
    • getIdentifierFactory

      public @NonNull JavaIdentifierFactory getIdentifierFactory()
      Description copied from interface: View
      Returns the IdentifierFactory for this view.
    • getCachedClassesCount

      public int getCachedClassesCount()
      Returns the number of classes that are currently stored in the cache.
    • getClassSource

      protected @NonNull Optional<JavaSootClassSource> getClassSource(@NonNull ClassType type)
    • buildClassFrom

      protected @NonNull JavaSootClass buildClassFrom(JavaSootClassSource classSource)