Interface LoadingStrategy
- All Known Implementing Classes:
EagerLoadingStrategy,OnDemandLoadingStrategy
JavaView resolves its classes: on demand (lazily, on first lookup) or
eagerly (all at once, at construction time). Injected into JavaView's constructor,
mirroring how a ClassCacheProvider supplies the view's ClassCache.
Implementations live in sootup.java.core.views, the same package as JavaView,
because resolveOnCacheMiss(sootup.java.core.views.JavaView, sootup.core.types.ClassType) and the default initialize(sootup.java.core.views.JavaView) need to call JavaView's protected getClassSource/buildClassFrom/
inputLocations through a JavaView-typed parameter - which only compiles for same-package
callers, not arbitrary subclasses (JLS 6.6.2).
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull LoadingStrategyeager()default voidinitialize(@NonNull JavaView view) Called exactly once, as the last statement ofJavaView's constructor, after all ofJavaView's own fields (inputLocations,cache,loadingStrategy,identifierFactory) have been assigned.default voidmakeAvailable(@NonNull ClassType type) Called fromJavaView.forgetAbsence(ClassType), itself called e.g. whenMutableJavaView.addClass(sootup.java.core.JavaSootClass)makes a previously-absent type available.static @NonNull LoadingStrategyonDemand()@NonNull Optional<JavaSootClass>resolveOnCacheMiss(@NonNull JavaView view, @NonNull ClassType type) Called fromJavaView.getClass(ClassType)after a cache miss, while holding the owning view's monitor.
-
Method Details
-
onDemand
-
eager
-
initialize
Called exactly once, as the last statement ofJavaView's constructor, after all ofJavaView'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
viewmust not depend on subclass fields that a subclass constructor would otherwise have initialized first. Do not wire the eager strategy into aJavaViewsubclass that overridesgetClasses()orbuildClassFrom(...)without re-checking this. -
resolveOnCacheMiss
@NonNull Optional<JavaSootClass> resolveOnCacheMiss(@NonNull JavaView view, @NonNull ClassType type) Called fromJavaView.getClass(ClassType)after a cache miss, while holding the owning view's monitor. Returns the resolved class, orOptional.empty()iftypecannot be resolved. -
makeAvailable
Called fromJavaView.forgetAbsence(ClassType), itself called e.g. whenMutableJavaView.addClass(sootup.java.core.JavaSootClass)makes a previously-absent type available. The default does nothing, which is correct for the eager strategy: it tracks no absence state to forget, since a class absent after an eager load can never become present.
-