Class EagerLoadingStrategy

java.lang.Object
sootup.java.core.views.EagerLoadingStrategy
All Implemented Interfaces:
LoadingStrategy

public class EagerLoadingStrategy extends Object implements LoadingStrategy
Resolves every class of a JavaView up front, at construction time, then releases the view's input locations. Used by JavaEagerView.

Since initialize(sootup.java.core.views.JavaView) has already resolved (and cached) everything reachable, a class not found in the cache by the time resolveOnCacheMiss(sootup.java.core.views.JavaView, sootup.core.types.ClassType) runs will never be found - there is nothing left to probe, and the input locations are closed besides. This carries no absence-set bookkeeping, unlike OnDemandLoadingStrategy, because none is needed.

  • Constructor Details

    • EagerLoadingStrategy

      public EagerLoadingStrategy()
  • Method Details

    • initialize

      public void initialize(@NonNull JavaView view)
      Description copied from interface: LoadingStrategy
      Called exactly once, as the last statement of JavaView's constructor, after all of JavaView's own fields (inputLocations, cache, loadingStrategy, identifierFactory) have been assigned. The default does nothing; only the eager strategy overrides this to resolve every class up front.

      Because this runs before any subclass's own constructor body, any virtual call this makes on view must not depend on subclass fields that a subclass constructor would otherwise have initialized first. Do not wire the eager strategy into a JavaView subclass that overrides getClasses() or buildClassFrom(...) without re-checking this.

      Specified by:
      initialize in interface LoadingStrategy
    • resolveOnCacheMiss

      public @NonNull Optional<JavaSootClass> resolveOnCacheMiss(@NonNull JavaView view, @NonNull ClassType type)
      Description copied from interface: LoadingStrategy
      Called from JavaView.getClass(ClassType) after a cache miss, while holding the owning view's monitor. Returns the resolved class, or Optional.empty() if type cannot be resolved.
      Specified by:
      resolveOnCacheMiss in interface LoadingStrategy