Package it.unive.lisa

Class LiSAFactory


  • public final class LiSAFactory
    extends java.lang.Object
    An utility class for instantiating analysis components, that is, modular pieces of the analysis that have several implementations. The default instance for a component can be retrieved through getDefaultFor(Class, Object...), while a specific instance can be retrieved through getInstance(Class, Object...). Note that custom defaults for each component can be defined through registerDefaultFor(Class, Class).
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  LiSAFactory.ConfigurableComponent<T>
      An analysis component that can be configured, that is, it has more than one implementation that can be modularly integrated into the analysis.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Collection<LiSAFactory.ConfigurableComponent<?>> configurableComponents()
      Yields the collection of LiSAFactory.ConfigurableComponents that can be used to customize the analysis.
      static <T> T getDefaultFor​(java.lang.Class<T> component, java.lang.Object... params)
      Builds the default instance of the specified analysis component.
      static <T> T getInstance​(java.lang.Class<T> component, java.lang.Object... params)
      Creates an instance of the given component.
      static void registerDefaultFor​(java.lang.Class<?> component, java.lang.Class<?> defaultImplementation)
      Registers a default implementation for component, taking precedence over the predefined defaults.
      static void registerDefaultParametersFor​(java.lang.Class<?> component, java.lang.Class<?>... defaultParameters)
      Registers the types (i.e.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static <T> T getInstance​(java.lang.Class<T> component,
                                        java.lang.Object... params)
                                 throws it.unive.lisa.AnalysisSetupException
        Creates an instance of the given component. If params are provided, a suitable (and not ambiguous) constructor must exist in component's class. If no params have been provided but default parameters have been registered through registerDefaultParametersFor(Class, Class...), getInstance(Class, Object...) will be used to create such parameters and those will be used. Otherwise, the nullary constructor of component is invoked.
        Type Parameters:
        T - the type of the component
        Parameters:
        component - the component to instantiate
        params - the parameters for the creation
        Returns:
        an instance of the given component
        Throws:
        it.unive.lisa.AnalysisSetupException - if the component cannot be created
      • registerDefaultFor

        public static void registerDefaultFor​(java.lang.Class<?> component,
                                              java.lang.Class<?> defaultImplementation)
        Registers a default implementation for component, taking precedence over the predefined defaults. Any previous default for component introduced by calling this method is removed.
        Parameters:
        component - the component whose default implementation is to be registered
        defaultImplementation - the new default implementation for component
      • registerDefaultParametersFor

        public static void registerDefaultParametersFor​(java.lang.Class<?> component,
                                                        java.lang.Class<?>... defaultParameters)
        Registers the types (i.e. implementations) of the parameters to use for the creation of the given component. These will be used whenever getInstance(Class, Object...) or getDefaultFor(Class, Object...) are invoked without specifying parameters but a default exist. Any previous default for component introduced by calling this method is removed.
        Parameters:
        component - the component whose default parameters are to be registered
        defaultParameters - the new parameters for the creation of component
      • getDefaultFor

        public static <T> T getDefaultFor​(java.lang.Class<T> component,
                                          java.lang.Object... params)
                                   throws it.unive.lisa.AnalysisSetupException
        Builds the default instance of the specified analysis component. The instance to create is retrieved by first looking into the custom defaults provided through registerDefaultFor(Class, Class). If no entry for component has been provided, then the instance is looked up in the predefined defaults. If component does not have a predefined default, then an AnalysisSetupException is thrown. Then, getInstance(Class, Object...) is invoked on the retrieved instance, using the given params. If no params have been provided but default parameters have been registered through registerDefaultParametersFor(Class, Class...), getInstance(Class, Object...) will be used to create such parameters and those will be used. If the default instance is a NonRelationalDomain and the component is a HeapDomain or ValueDomain, then the instance is wrapped into the appropriate environment (either HeapEnvironment or ValueEnvironment) before being returned.
        Type Parameters:
        T - the type of the component
        Parameters:
        component - the component to instantiate
        params - the parameters for the creation of the default instance
        Returns:
        an instance of the default implementation of the given component
        Throws:
        it.unive.lisa.AnalysisSetupException - if the default implementation cannot be created