Class OnDemandLoadingStrategy
- All Implemented Interfaces:
LoadingStrategy
LoadingStrategy for JavaView.
Memoizes types that no AnalysisInputLocation could provide a
class source for. The owning view's positive cache only memoizes successful resolutions,
so without this every repeated lookup of an absent type would re-run getClassSource,
which probes every input location - including the JDK jimage filesystem - while holding the
view's monitor. Call graph construction against an incomplete classpath does exactly that: it
repeats a handful of failing lookups thousands of times.
Not thread-safe on its own; callers only touch absentClasses while holding the owning
JavaView's monitor (see JavaView.getClass(ClassType) / JavaView.forgetAbsence(ClassType), both synchronized). Do not share one instance of this
class across multiple JavaViews - each view's absence record is instance state, not a
shared cache.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidmakeAvailable(@NonNull ClassType type) Called fromJavaView.forgetAbsence(ClassType), itself called e.g. whenMutableJavaView.addClass(sootup.java.core.JavaSootClass)makes a previously-absent type available.@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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface sootup.java.core.views.LoadingStrategy
initialize
-
Field Details
-
absentClasses
-
-
Constructor Details
-
OnDemandLoadingStrategy
public OnDemandLoadingStrategy()
-
-
Method Details
-
resolveOnCacheMiss
public @NonNull Optional<JavaSootClass> resolveOnCacheMiss(@NonNull JavaView view, @NonNull ClassType type) Description copied from interface:LoadingStrategyCalled fromJavaView.getClass(ClassType)after a cache miss, while holding the owning view's monitor. Returns the resolved class, orOptional.empty()iftypecannot be resolved.- Specified by:
resolveOnCacheMissin interfaceLoadingStrategy
-
makeAvailable
Description copied from interface:LoadingStrategyCalled 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.- Specified by:
makeAvailablein interfaceLoadingStrategy
-