package cg
- Alphabetic
- Public
- All
Type Members
- abstract class AbstractClassExtensibility extends ClassExtensibility
-
abstract
class
ClassExtensibility extends (ObjectType) ⇒ Answer
Determines whether a class or interface is directly extensible by a (yet unknown) client application/library.
Determines whether a class or interface is directly extensible by a (yet unknown) client application/library. A class/interface is directly extensible if a developer can define a direct - not transitive - subtype that is not part of the given application/library.
This analysis uses the ClosedPackages information.
- class ClassHierarchyIsNotExtensible extends ClassExtensibility
-
class
ClosedCodeBase extends ClosedPackages
Treats all packages as being closed.
Treats all packages as being closed. This analysis is useable, e.g., for simple applications which have no concept of plug-ins or a similar mechanism. In this case every package is supposed to be closed since the entire code base is available at analysis time. Generally, not useable for libraries/frameworks/code which can be "freely" extended.
To use this analysis set the config key:
org.opalj.br.analyses.cg.ClosedPackagesKey.analysistoorg.opalj.br.analyses.cg.ClosedCodeBase- Note
An application that uses reflection to load functionality at runtime has a well-defined extension point and is not a simple application in the above sense.
-
abstract
class
ClosedPackages extends (String) ⇒ Boolean
Determines which packages are open or closed; that is, determines to which packages code - which is not yet known - can potentially be contributed to.
Determines which packages are open or closed; that is, determines to which packages code - which is not yet known - can potentially be contributed to. In other words, a package is considered open, if a developer is allowed to define a new type within the package's namespace. If a developer cannot define a new type within the package's namespace, the package is considered closed.
An example for closed packages are the packages within the java.* namespace of the JRE. Additionally, with Java 9 packages defined in modules can be considered closed.
The set of open/closed packages may influence call-graph construction as well as other analyses.
The concrete set of open/closed packages is specified in OPAL's configuration file. The relevant configuration key is:
org.opalj.br.analyses.cg.ClosedPackagesKey.The concrete analysis which determines the open/closed packages is instantiated reflectively by ClosedPackagesKey. This facilitates the configuration of project specific closed packages. The class can be configured using the config key:
org.opalj.br.analyses.cg.ClosedPackagesKey.analysis={ClosedPackagesAnalysis}- Note
The concept of open and closed packages - and the reason why it matters - is discussed in "Call Graph Construction for Java Libraries"
-
class
ClosedPackagesConfiguration extends ClosedPackages
Determines the closed packages using a regular expression.
Determines the closed packages using a regular expression.
The regular expression can be defined using the general configuration key:
org.opalj.br.analyses.cg.ClosedPackagesKey.closedPackagesorg.opalj.br.analyses.cg.ClosedPackagesKey.closedPackages = "java/*|com/sun/*"The previous example treats all packages starting with
javaandcom.sunas closed.
Example: -
class
ConfiguredExtensibleClasses extends AbstractClassExtensibility
Determines whether a type is directly extensible by a (yet unknown) client application/library using the base analysis ClassExtensibility and an explicitly configured list of extensible types where the list overrides the findings of the analysis.
Determines whether a type is directly extensible by a (yet unknown) client application/library using the base analysis ClassExtensibility and an explicitly configured list of extensible types where the list overrides the findings of the analysis. This enables domain specific configurations.
Additional configuration has to be done using OPAL's configuration file. To specify extensible classes/interfaces the following key has to be used:
ClassExtensibilityKey.ConfigKeyPrefix + extensibleClassesThe following example configuration would consider
java/util/Mathandcom/example/Typeas extensible.org.opalj.br.analyses.ClassExtensibilityKey.extensibleClasses = ["java/util/Math", "com/example/Type"]
Example: -
class
ConfiguredFinalClasses extends AbstractClassExtensibility
Determines whether a type is directly extensible by a (yet unknown) client application/library using the base analysis ClassExtensibility and an explicitly configured list of final (not extensible) types; the configuration is always considered first.
Determines whether a type is directly extensible by a (yet unknown) client application/library using the base analysis ClassExtensibility and an explicitly configured list of final (not extensible) types; the configuration is always considered first. This enables domain specific configurations.
Additional configuration has to be done using OPAL's configuration file. To specify classes/interfaces that are not extensible/that are final the following key has to be used:
ClassExtensibilityKey.ConfigKeyPrefix + finalClassesThe following example configuration would consider
java/util/Mathandcom/exmaple/Typeas not extensible.org.opalj.br.analyses.ClassExtensibilityKey.finalClasses = ["java/util/Math", "com/example/Type"]
Example: - class DefaultClassExtensibility extends AbstractClassExtensibility
-
class
OpenCodeBase extends ClosedPackages
A conservative ClosedPackages analysis which considers all packages (except of those starting with
java) as being open.A conservative ClosedPackages analysis which considers all packages (except of those starting with
java) as being open. Thejava.*packages are protected by the JVM itself. This analysis can safely be used by every analysis, but - depending on the context - may result in imprecise analysis results.To use this analysis set the config key:
org.opalj.br.analyses.ClosedPackagesKey.analysistoorg.opalj.br.analyses.OpenCodeBase -
class
TypeExtensibilityAnalysis extends (ObjectType) ⇒ Answer
Determines if a type (class or interface) is further (transitively) extensible by yet unknown types (that is, can be (transitively) inherited from).
Determines if a type (class or interface) is further (transitively) extensible by yet unknown types (that is, can be (transitively) inherited from).
Special cases
If a class is defined in a package starting with java.*, it always has to be treated like classes that belong to a closed package. This is necessary because the default
ClassLoaderprevents the definition of further classes within these packages, hence, they are closed by definition.If the analyzed codebase has an incomplete type hierarchy, which leads to unknown subtype relationships, it is necessary to add these particular classes to the computed set of extensible classes.
Value Members
-
object
ClassExtensibilityKey extends ProjectInformationKey[ClassExtensibility, Nothing]
The key object to get a function that determines whether a type is directly extensible or not.
The key object to get a function that determines whether a type is directly extensible or not.
- See also
ClassExtensibility for further information.
-
object
ClosedPackagesKey extends ProjectInformationKey[ClosedPackages, Nothing]
The key object to get a function that determines whether a package is closed or not.
The key object to get a function that determines whether a package is closed or not. See ClosedPackages for further details.
This key reflectively instantiates the analysis that determines whether a package is closed or not. The respective analysis has to extend the abstract ClosedPackages class. To configure which analysis is used use the key
org.opalj.br.analyses.cg.ClosedPackagesKey.analysisto specify the name of the class which implements the analysis.org.opalj.br.analyses { ClosedPackagesKey { analysis = "org.opalj.br.analyses.ClosedPackagesConfiguration" closedPackages = "java(/.*)*" } }- Note
Please see the documentation of ClosedPackages and its subtypes for more information.
,The default configuration is the conservative OpenCodeBase analysis.
Example: -
object
IsOverridableMethodKey extends ProjectInformationKey[(Method) ⇒ Answer, Nothing]
The key object to get a function that determines whether a method can be overridden by a not yet existing type.
The key object to get a function that determines whether a method can be overridden by a not yet existing type. A method can be overridden if it's declaring type _dt_is extensible by an (unknown) type _ut_ (e.g., when the analysis assumes an open world) and if the method is not overridden by another subtype _s_ such that _ut <: s <: st_ and if the method can be overridden according to the JVM's semantics.
-
object
TypeExtensibilityKey extends ProjectInformationKey[(ObjectType) ⇒ Answer, Nothing]
Key to get the function that determines whether a type (i.e., we abstrat over a class/ interface and all its subtypes) is extensible or not. A type is extensible if a developer could define a sub(*)type that is not part of the given application/library.