class Project[Source] extends ProjectLike
Primary abstraction of a Java project; i.e., a set of classes that constitute a library, framework or application as well as the libraries or frameworks used by the former.
This class has several purposes:
- It is a container for
ClassFile
s. - It directly gives access to the project's class hierarchy.
- It serves as a container for project-wide information (e.g., a call graph,
information about the mutability of classes, constant values,...) that can
be queried using org.opalj.br.analyses.ProjectInformationKeys.
The list of project wide information that can be made available is equivalent
to the list of (concrete/singleton) objects implementing the trait
org.opalj.br.analyses.ProjectInformationKey.
One of the most important project information keys is the
PropertyStoreKey
which gives access to the property store.
Thread Safety
This class is thread-safe.
Prototyping Analyses/Querying Projects
Projects can easily be created and queried using the Scala REPL
. For example,
to create a project, you can use:
val project = org.opalj.br.analyses.Project(org.opalj.bytecode.JRELibraryFolder)
Now, to determine the number of methods that have at least one parameter of type
int
, you can use:
project.methods.filter(_.parameterTypes.exists(_.isIntegerType)).size
- Source
The type of the source of the class file. E.g., a
URL
, aFile
, aString
or a Pair(JarFile,JarEntry)
. This information is needed for, e.g., presenting users meaningful messages w.r.t. the location of issues. We abstract over the type of the resource to facilitate the embedding in existing tools such as IDEs. E.g., in EclipseIResource
's are used to identify the location of a resource (e.g., a source or class file.)
- Source
- Project.scala
- Alphabetic
- By Inheritance
- Project
- ProjectLike
- ClassFileRepository
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final val MethodHandleClassFile: Option[ClassFile]
The class file of
java.lang.invoke.MethodHandle
, if available.The class file of
java.lang.invoke.MethodHandle
, if available.- Definition Classes
- Project → ProjectLike
- final val MethodHandleSubtypes: Set[ObjectType]
The set of all subtypes of
java.lang.invoke.MethodHandle
; in particular required to resolve signature polymorphic method calls.The set of all subtypes of
java.lang.invoke.MethodHandle
; in particular required to resolve signature polymorphic method calls.- Definition Classes
- Project → ProjectLike
- final val ObjectClassFile: Option[ClassFile]
The class file of
java.lang.Object
, if available.The class file of
java.lang.Object
, if available.- Definition Classes
- Project → ProjectLike
- final val VarHandleClassFile: Option[ClassFile]
The class file of
java.lang.invoke.VarHandle
, if available.The class file of
java.lang.invoke.VarHandle
, if available.- Definition Classes
- Project → ProjectLike
- final val VarHandleSubtypes: Set[ObjectType]
The set of all subtypes of
java.lang.invoke.VarHandle
; in particular required to resolve signature polymorphic method calls.The set of all subtypes of
java.lang.invoke.VarHandle
; in particular required to resolve signature polymorphic method calls.- Definition Classes
- Project → ProjectLike
- final val allClassFiles: Iterable[ClassFile]
- Definition Classes
- Project → ProjectLike
- final val allFields: Iterable[Field]
- final val allLibraryClassFiles: ArraySeq[ClassFile]
- final val allMethods: Iterable[Method]
- final val allMethodsWithBody: ArraySeq[Method]
- final val allMethodsWithBodyWithContext: ArraySeq[MethodInfo[Source]]
- final val allProjectClassFiles: ArraySeq[ClassFile]
- final val allSourceElements: Iterable[SourceElement]
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def availableProjectInformation: List[AnyRef]
Returns the additional project information that is currently available.
Returns the additional project information that is currently available.
If some analyses are still running it may be possible that additional information will be made available as part of the execution of those analyses.
- Note
This method redetermines the available project information on each call.
- def classFile(objectType: ObjectType): Option[ClassFile]
Returns the class file that defines the given
objectType
; if any.Returns the class file that defines the given
objectType
; if any.- objectType
Some object type.
- Definition Classes
- Project → ClassFileRepository
- final val classFilesCount: Int
- def classFilesWithSources: Iterable[(ClassFile, Source)]
- final val classHierarchy: ClassHierarchy
- Definition Classes
- Project → ProjectLike
- final val classesPerPackage: Map[String, Set[ClassFile]]
The set of all classes defined in a specific package.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- final val codeSize: Long
- implicit final val config: Config
- Definition Classes
- Project → ProjectLike
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def extend(other: Project[Source]): Project[Source]
Creates a new
Project
which also includes this as well as the other project's class files. - def extend(projectClassFilesWithSources: Iterable[(ClassFile, Source)]): Project[Source]
Creates a new
Project
which also includes the given class files. - final val fieldsCount: Int
- def finalize(): Unit
Unregisters this project from the OPALLogger and then calls
super.finalize
.Unregisters this project from the OPALLogger and then calls
super.finalize
.- Attributes
- protected
- Definition Classes
- Project → AnyRef
- def findMaximallySpecificSuperinterfaceMethods(superinterfaceTypes: UIDSet[ObjectType], name: String, descriptor: MethodDescriptor, analyzedSuperinterfaceTypes: UIDSet[ObjectType]): (UIDSet[ObjectType], Set[Method])
Computes the maximally specific superinterface method with the given name and descriptor
Computes the maximally specific superinterface method with the given name and descriptor
- superinterfaceTypes
A set of interfaces which potentially declare a method with the given name and descriptor.
- Definition Classes
- ProjectLike
- def findMaximallySpecificSuperinterfaceMethods(superinterfaceType: ObjectType, name: String, descriptor: MethodDescriptor, analyzedSuperinterfaceTypes: UIDSet[ObjectType] = UIDSet.empty): (UIDSet[ObjectType], Set[Method])
Computes the set of maximally specific superinterface methods with the given name and descriptor.
Computes the set of maximally specific superinterface methods with the given name and descriptor.
- Definition Classes
- ProjectLike
- Note
This method does not consider methods defined by
java.lang.Object
! Those methods have precedence over respective methods defined by superinterfaces! A corresponding check needs to be done before calling this method.
- final lazy val functionalInterfaces: UIDSet[ObjectType]
Computes the set of all definitive functional interfaces in a top-down fashion.
Computes the set of all definitive functional interfaces in a top-down fashion.
- returns
The functional interfaces.
- See also
Java 8 language specification for details!
- def get[T <: AnyRef](pik: ProjectInformationKey[T, _]): T
Returns the information attached to this project that is identified by the given
ProjectInformationKey
.Returns the information attached to this project that is identified by the given
ProjectInformationKey
.If the information was not yet required, the information is computed and returned. Subsequent calls will directly return the information.
- Note
(Development Time) Every analysis using ProjectInformationKeys must list All requirements; failing to specify a requirement can end up in a deadlock.
- See also
ProjectInformationKey for further information.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def getOrCreateProjectInformationKeyInitializationData[T <: AnyRef, I <: AnyRef](key: ProjectInformationKey[T, I], info: => I): I
Gets the project information key specific initialization object.
Gets the project information key specific initialization object. If an object is already registered, that object will be used otherwise
info
will be evaluated and that value will be added and also returned.- Note
Initialization data is discarded once the key is used.
- def getProjectInformationKeyInitializationData[T <: AnyRef, I <: AnyRef](key: ProjectInformationKey[T, I]): Option[I]
Returns the project specific initialization information for the given project information key.
- def groupedClassFilesWithMethodsWithBody(groupsCount: Int): Array[Buffer[ClassFile]]
Distributes all classes which define methods with bodies across a given number of groups.
Distributes all classes which define methods with bodies across a given number of groups. Afterwards these groups can, e.g., be processed in parallel.
- def has[T <: AnyRef](pik: ProjectInformationKey[T, _]): Option[T]
Tests if the information identified by the given ProjectInformationKey is available.
Tests if the information identified by the given ProjectInformationKey is available. If the information is not (yet) available, the information will not be computed;
None
will be returned.- See also
ProjectInformationKey for further information.
- def hasInstanceMethod(receiverType: ObjectType, name: String, descriptor: MethodDescriptor, isPackagePrivate: Boolean): Boolean
- def hasVirtualMethod(objectType: ObjectType, method: Method): Answer
Tests if the given method belongs to the interface of an object identified by the given
objectType
.Tests if the given method belongs to the interface of an object identified by the given
objectType
. I.e., returnstrue
if a virtual method call, where the receiver type is known to have the givenobjectType
, would lead to the direct invocation of the givenmethod
. The given method can be an inherited method, but it will never returnYes
if the given method is overridden byobjectType
or a supertype of it which is a sub type of the declaring type ofmethod
.- Definition Classes
- ProjectLike
- Note
The computation is based on the computed set of instanceMethods and generally requires at most O(n log n) steps where n is the number of callable instance methods of the given object type; the class hierarchy is not traversed.
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def instanceCall(callerClassType: ObjectType, receiverType: ReferenceType, name: String, descriptor: MethodDescriptor): Result[Method]
Returns the (instance) method that would be called when we have an instance of the given receiver type.
Returns the (instance) method that would be called when we have an instance of the given receiver type. I.e., using this method is suitable only when the runtime type, which is the receiver of the method call, is precisely known!
Examples
class A {def foo() = {} } class B extends A {/*inherits, but does not override foo()*/} class C extends B { def foo() = {} } val b = new B(); b.foo() // <= in this case the method defined by A will be returned. val c = new C(); c.foo() // <= in this case the method defined by C will be returned.
This method supports default methods and signature polymorphic calls; i.e., the descriptor of the retuned methods may not be equal to the given method descriptor.
- callerClassType
The object type which defines the method which performs the call. This information is required if the call target has (potentially) default visibility. (Note that this - in general - does not replace the need to perform an accessibility check.)
- receiverType
A class type or an array type; never an interface type.
- Definition Classes
- ProjectLike
- final val instanceMethods: Map[ObjectType, ArraySeq[MethodDeclarationContext]]
Returns the set of all non-private, non-abstract, non-static methods that are not initializers and which are potentially callable by clients when we have an object that has the specified type and a method is called using org.opalj.br.instructions.INVOKEINTERFACE, org.opalj.br.instructions.INVOKEVIRTUAL or org.opalj.br.instructions.INVOKEDYNAMIC.
Returns the set of all non-private, non-abstract, non-static methods that are not initializers and which are potentially callable by clients when we have an object that has the specified type and a method is called using org.opalj.br.instructions.INVOKEINTERFACE, org.opalj.br.instructions.INVOKEVIRTUAL or org.opalj.br.instructions.INVOKEDYNAMIC.
The array of methods is sorted using MethodDeclarationContextOrdering to enable fast look-up of the target method. (See MethodDeclarationContext's
compareAccessibilityAware
method for further details.)- Definition Classes
- Project → ProjectLike
- def interfaceCall(callerType: ObjectType, declaringClass: ObjectType, name: String, descriptor: MethodDescriptor): Set[Method]
Returns the methods that may be called by an org.opalj.br.instructions.INVOKEINTERFACE call if the precise runtime type is not known.
Returns the methods that may be called by an org.opalj.br.instructions.INVOKEINTERFACE call if the precise runtime type is not known. (If the precise runtime type is known, use
instanceCall
to get the target method.)- returns
The set of potentially called methods. The set will be empty if the target class is not defined as part of the analyzed code base.
- Definition Classes
- ProjectLike
- Note
Caching the result (in particular when the call graph is computed) is recommended as the computation is expensive. In other words, this function is meant to be used as a foundation for call graph construction algorithms.
,Keep in mind that the following is legal (byte)code:
class X { void m(){ System.out.println("X.m"); } } interface I { void m(); } class Z extends X implements I {}
Hence, we also have to consider inherited methods and just considering the methods defined by subclasses is not sufficient! In other words, the result can contain methods (here,
X.m
) defined by classes which are not subtypes of the given interface type!
- def interfaceCall(callerType: ObjectType, i: INVOKEINTERFACE): Set[Method]
- Definition Classes
- ProjectLike
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isLibraryType(objectType: ObjectType): Boolean
Returns
true
if the given type belongs to the library part of the project.Returns
true
if the given type belongs to the library part of the project. This is generally the case if no class file was loaded for the given type. - def isLibraryType(classFile: ClassFile): Boolean
Returns
true
if the given class file belongs to the library part of the project.Returns
true
if the given class file belongs to the library part of the project. This is only the case if the class file was explicitly identified as being part of the library. By default all class files are considered to belong to the code base that will be analyzed. - def isProjectType(objectType: ObjectType): Boolean
Returns
true
iff the given type belongs to the project and not to a library. - def isSignaturePolymorphic(definingClassType: ObjectType, name: String, descriptor: MethodDescriptor): Boolean
Returns true if the signature is a signature polymorphic method for the given class type.
Returns true if the signature is a signature polymorphic method for the given class type. (See JVM 9 Spec. for details.)
- Definition Classes
- ProjectLike
- def isSignaturePolymorphic(definingClassType: ObjectType, descriptor: MethodDescriptor): Boolean
Returns true if the descriptor is a signature polymorphic method for the given class type.
Returns true if the descriptor is a signature polymorphic method for the given class type. (See JVM 9 Spec. for details.)
- Definition Classes
- ProjectLike
- def isSignaturePolymorphic(definingClassType: ObjectType, method: Method): Boolean
Returns true if the method defined by the given class type is a signature polymorphic method.
Returns true if the method defined by the given class type is a signature polymorphic method. (See JVM 9 Spec. for details.)
- Definition Classes
- ProjectLike
- final val libraryClassFilesAreInterfacesOnly: Boolean
- final val libraryClassFilesCount: Int
- def libraryClassFilesWithSources: Iterable[(ClassFile, Source)]
- final val libraryFieldsCount: Int
- final val libraryMethodsCount: Int
- def libraryPackages: Set[String]
Returns the set of all library packages that contain at least one class.
Returns the set of all library packages that contain at least one class.
For example, in case of the JDK the package
java
does not directly contain any class – only its subclasses. This package is, hence, not returned by this function, but the packagejava.lang
is.- Note
This method's result is not cached.
- implicit final val logContext: LogContext
- Definition Classes
- Project → ClassFileRepository
- def lookupClassFiles(objectTypes: Iterable[ObjectType])(classFileFilter: (ClassFile) => Boolean): Iterable[ClassFile]
Returns all available
ClassFile
objects for the givenobjectTypes
that pass the givenfilter
.Returns all available
ClassFile
objects for the givenobjectTypes
that pass the givenfilter
.ObjectType
s for which noClassFile
is available are ignored. - def lookupVirtualMethod(callingContextType: ObjectType, receiverType: ObjectType, name: String, descriptor: MethodDescriptor): Result[MethodDeclarationContext]
Looks up the method (declaration context) which is accessible/callable by an org.opalj.br.instructions.INVOKEVIRTUAL or org.opalj.br.instructions.INVOKEINTERFACE call which was done by a method belonging to
callingContextType
.Looks up the method (declaration context) which is accessible/callable by an org.opalj.br.instructions.INVOKEVIRTUAL or org.opalj.br.instructions.INVOKEINTERFACE call which was done by a method belonging to
callingContextType
. ThecallingContextType
is only relevant in case the target method has default visibility; in this case it is checked whether the caller belongs to the same context.- returns
Success if the method is found; Empty$ if the method cannot be found and Failure$ if the method cannot be found because the project is definitively inconsistent.
Failure$
is used on a best-effort basis.
- Definition Classes
- ProjectLike
- Note
This method uses the pre-computed information about instance methods and, therefore, does not require a type hierarchy based lookup.
,It supports the lookup of polymorphic methods.
- def methodNames(objectTypes: Iterable[ObjectType]): Set[String]
The set of all method names of the given types.
- final val methodsCount: Int
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final val nests: Map[ObjectType, ObjectType]
Returns the nest host (see JVM 11 Spec.
Returns the nest host (see JVM 11 Spec. 5.4.4) for the given type, if explicitly given. For classes without an explicit NestHost or NestMembers attribute, the type itself is the nest host, but this is NOT recorded in this map.
- Definition Classes
- Project → ProjectLike
- def nonVirtualCall(callerClassType: ObjectType, i: NonVirtualMethodInvocationInstruction): Result[Method]
- Definition Classes
- ProjectLike
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- def overriddenBy(m: Method): Set[Method]
Returns the set of methods which directly override the given method.
Returns the set of methods which directly override the given method. Note that
overriddenBy
is not context aware. I.e., if a given methodm
is an interface method, then it may happen that we have an implementation of that method in a class which is inherited from a superclass which is not a subtype of the interface. That method - since it is not defined by a subtype of the interface - would not be included in the returned set. An example is shown next:class X { void m(){ System.out.println("X.m"); } interface Y { default void m(){ System.out.println("Y.m"); } class Z extends X implements Y { // Z inherits m() from X; hence, X.m() (in this context) "overrides" Y.m(), but is not // returned by this function. To also identify X.m() you have to combine the results // of overridenBy and instanceMethods(!). }
- Definition Classes
- ProjectLike
- final val overridingMethods: Map[Method, Set[Method]]
Stores for each non-private, non-initializer method the set of methods which override a specific method.
Stores for each non-private, non-initializer method the set of methods which override a specific method. If the given method is a concrete method, this method is also included in the set of
overridingMethods
.- Definition Classes
- Project → ProjectLike
- def packages: Set[String]
Returns the list of all packages that contain at least one class.
Returns the list of all packages that contain at least one class.
For example, in case of the JDK the package
java
does not directly contain any class – only its subclasses. This package is, hence, not returned by this function, but the packagejava.lang
is.- Note
This method's result is not cached.
- def packagesCount: Int
Number of packages.
Number of packages.
- Note
The result is (re)calculated for each call.
- def parForeachClassFile[T](isInterrupted: () => Boolean = defaultIsInterrupted)(f: (ClassFile) => T): Unit
- def parForeachLibraryClassFile[T](isInterrupted: () => Boolean = defaultIsInterrupted)(f: (ClassFile) => T): Unit
- def parForeachMethod[T](isInterrupted: () => Boolean = defaultIsInterrupted)(f: (Method) => T): Unit
Iterates over all methods in parallel; actually, the methods belonging to a specific class are analyzed sequentially..
- def parForeachMethodWithBody[T](isInterrupted: () => Boolean = defaultIsInterrupted, parallelizationLevel: Int = NumberOfThreadsForCPUBoundTasks)(f: (MethodInfo[Source]) => T): Unit
Iterates over all methods with a body in parallel starting with the largest methods first.
Iterates over all methods with a body in parallel starting with the largest methods first.
This method maximizes utilization by allowing each thread to pick the next unanalyzed method as soon as the thread has finished analyzing the previous method. I.e., each thread is not assigned a fixed batch of methods. Additionally, the methods are analyzed ordered by their length (longest first).
- def parForeachProjectClassFile[T](isInterrupted: () => Boolean = defaultIsInterrupted)(f: (ClassFile) => T): Unit
- final val projectClassFilesCount: Int
- def projectClassFilesWithSources: Iterable[(ClassFile, Source)]
- def projectClassMembersPerClassDistribution: Map[Int, (Int, Set[String])]
Returns the number of (non-synthetic) fields and methods per class file.
Returns the number of (non-synthetic) fields and methods per class file. The number of class members of nested classes is also taken into consideration. I.e., the map's key identifies the category and the value is a pair where the first value is the count and the value is the names of the source elements.
The count can be higher than the set of names of class members due to method overloading.
- final val projectFieldsCount: Int
- final val projectMethodsCount: Int
- def projectMethodsLengthDistribution: Map[Int, Set[Method]]
Returns the (number of) (non-synthetic) methods per method length (size in length of the method's code array).
- def projectPackages: Set[String]
Returns the set of all project packages that contain at least one class.
Returns the set of all project packages that contain at least one class.
For example, in case of the JDK the package
java
does not directly contain any class – only its subclasses. This package is, hence, not returned by this function, but the packagejava.lang
is.- Note
This method's result is not cached.
- def recreate(filterProjectInformation: (Int) => Boolean = _ => false): Project[Source]
Returns a shallow clone of this project with an updated log context and (optionally) filtered ProjectInformation objects.
Returns a shallow clone of this project with an updated log context and (optionally) filtered ProjectInformation objects.
- filterProjectInformation
Enables filtering of the ProjectInformation objects that should be kept when a new Project is created.
- def requiredJVMVersion: Int
Returns the minimum version number of the JVM required to run the code of the project, i.e., the maximum class file major version number of any class file in the project.
Returns the minimum version number of the JVM required to run the code of the project, i.e., the maximum class file major version number of any class file in the project.
- Definition Classes
- ProjectLike
- def resolveAllMethodReferences(declaringClassType: ReferenceType, name: String, descriptor: MethodDescriptor): Set[Method]
Resolves a method reference to all possible methods.
Resolves a method reference to all possible methods. I.e., this is identical to
resolveMethodReference
orresolveInterfaceMethodReference
for class and interface types respectively except for the case where there are multiple maximally specific interface methods in which case all of them are returned instead of only a single one.- declaringClassType
The type of the object that receives the method call. The type may be a class or interface type.
- returns
The set of resolved methods; empty if the resolution fails, more than one if resolution finds several maximally specific interface methods - in the latter case it is not possible to call the method on objects of the declaring class type, but only on subclasses overriding the method uniquely.
- Definition Classes
- ProjectLike
- def resolveClassMethodReference(receiverType: ObjectType, name: String, descriptor: MethodDescriptor): Result[Method]
Resolves a symbolic reference to a method defined by a class (not interface) type.
Resolves a symbolic reference to a method defined by a class (not interface) type.
- returns
org.opalj.Success
(method)
if the method was found;Empty
if the project is incomplete and the method could not be found;Failure
if the method could not be found though the project is seemingly complete. I.e., ifFailure
is returned the method is not defined by a concrete class and is either a default method defined by an interface or the analyzed code basis is inconsistent.
- Definition Classes
- ProjectLike
- final def resolveFieldReference(fieldAccess: FieldAccess): Option[Field]
- Definition Classes
- ProjectLike
- See also
- def resolveFieldReference(declaringClassFile: ClassFile, fieldName: String, fieldType: FieldType): Option[Field]
Resolves a symbolic reference to a field.
Resolves a symbolic reference to a field. Basically, the search starts with the given class
c
and then continues withc
's superinterfaces before the search is continued withc
's superclass (as prescribed by the JVM specification for the resolution of unresolved symbolic references).Resolving a symbolic reference is particularly required to, e.g., get a field's annotations or to get a field's value (if it is
static
,final
and has a constant value).- declaringClassFile
The class (or a superclass thereof) that is expected to define the specified field.
- fieldName
The name of the field.
- fieldType
The type of the field (the field descriptor).
- Definition Classes
- ProjectLike
- Note
This implementation does not check for
,IllegalAccessError
. This check needs to be done by the caller. The same applies for the check that the field is non-static if get-/putfield is used and static if a get-/putstatic is used to access the field. In the latter case the JVM would throw aLinkingException
. Furthermore, if the field cannot be found, it is the responsibility of the caller to handle that situation.Resolution is final. I.e., either this algorithm has found the defining field or the field is not defined by one of the loaded classes. Searching for the field in subclasses is not meaningful as it is not possible to override fields.
- final def resolveFieldReference(declaringClassType: ObjectType, fieldName: String, fieldType: FieldType): Option[Field]
- Definition Classes
- ProjectLike
- See also
- def resolveInterfaceMethodReference(i: INVOKEINTERFACE): Option[Method]
See #resolveInterfaceMethodReference(declaringClassType:* for details.
See #resolveInterfaceMethodReference(declaringClassType:* for details.
- Definition Classes
- ProjectLike
- def resolveInterfaceMethodReference(declaringClassType: ObjectType, name: String, descriptor: MethodDescriptor): Option[Method]
- Definition Classes
- ProjectLike
- def resolveMethodReference(i: INVOKEVIRTUAL): Option[Method]
See #resolveMethodReference(declaringClassType:* for details.
See #resolveMethodReference(declaringClassType:* for details.
- Definition Classes
- ProjectLike
- def resolveMethodReference(declaringClassType: ReferenceType, name: String, descriptor: MethodDescriptor, forceLookupInSuperinterfacesOnFailure: Boolean = false): Option[Method]
Tries to resolve a method reference as specified by the JVM specification.
Tries to resolve a method reference as specified by the JVM specification. I.e., the algorithm tries to find the class that actually declares the referenced method. Resolution of signature polymorphic method calls is also supported.
This method can be used as the basis for the implementation of the semantics of the
invokeXXX
instructions. However, it does not check whether the resolved method can be accessed by the caller or if it is abstract. Additionally, it is still necessary that the caller makes a distinction between the statically (at compile time) identified declaring class and the dynamic type of the receiver in case ofinvokevirtual
andinvokeinterface
instructions. I.e., additional processing is necessary on the client side.- declaringClassType
The type of the object that receives the method call. The type must be a class type and must not be an interface type. No check w.r.t. a potential
IncompatibleClassChangeError
is done by this method.- forceLookupInSuperinterfacesOnFailure
If true (default: false) the method tries to look up the method in a super interface if it can't find it in the available super classes.
- returns
The resolved method
Some(
METHOD)
orNone
. (To get the defining class file use the project's respective method.)
- Definition Classes
- ProjectLike
- Note
This method just resolves a method reference. Additional checks, such as whether the resolved method is accessible, may be necessary.
- def rootPackages: Map[String, String]
Determines for all packages of this project that contain at least one class the "root" packages and stores the mapping between the package and its root package.
Determines for all packages of this project that contain at least one class the "root" packages and stores the mapping between the package and its root package.
For example, let's assume that we have project which has the following packages that contain at least one class:
- org.opalj
- org.opalj.ai
- org.opalj.ai.domain
- org.apache.commons.io
- java.lang Then the map will be:
- org.opalj => org.opalj
- org.opalj.ai => org.opalj
- org.opalj.ai.domain => org.opalj
- org.apache.commons.io => org.apache.commons.io
- java.lang => java.lang
In other words the set of rootPackages can then be determined using:
<Project>.rootPackages().values.toSet
- returns
a Map which contains for each package name the root package name.
- Note
This method's result is not cached.
- def source(classFile: ClassFile): Option[Source]
- def source(objectType: ObjectType): Option[Source]
Returns the source (for example, a
File
object orURL
object) from which the class file was loaded that defines the given object type, if any.Returns the source (for example, a
File
object orURL
object) from which the class file was loaded that defines the given object type, if any.- objectType
Some object type.
- def sourceElementsCount: Int
The number of all source elements (fields, methods and class files).
- def specialCall(callerClassType: ObjectType, initialDeclaringClassType: ObjectType, isInterface: Boolean, name: String, descriptor: MethodDescriptor): Result[Method]
Returns the instance method/initializer which is called by an invokespecial instruction.
Returns the instance method/initializer which is called by an invokespecial instruction.
- returns
One of the following three values:
- org.opalj.Success
(method)
if the method was found; Failure
if the project is inconsistent; i.e., the target class file is found, but the method cannot be found.Failure
is returned on a best effort basis.Empty
.
- org.opalj.Success
- Definition Classes
- ProjectLike
- Note
Virtual method call resolution is not necessary; the call target is either a constructor, a method in the given class or a super method/constructor. However, in the first and last case it may be possible that we can't find the method because of an inconsistent or incomplete project.
- def specialCall(callerClassType: ObjectType, i: INVOKESPECIAL): Result[Method]
- Definition Classes
- ProjectLike
- def staticCall(callerClassType: ObjectType, declaringClassType: ObjectType, isInterface: Boolean, name: String, descriptor: MethodDescriptor): Result[Method]
Returns the method that will be called by the respective invokestatic call.
Returns the method that will be called by the respective invokestatic call.
- returns
org.opalj.Success
(method)
if the method was found;Failure
if the project is inconsistent.Empty
if the method could not be found in the available classes (i.e., the project is incomplete).
- Definition Classes
- ProjectLike
- def staticCall(callerClassType: ObjectType, i: INVOKESTATIC): Result[Method]
Returns the method which will be called by the respective org.opalj.br.instructions.INVOKESTATIC instruction.
Returns the method which will be called by the respective org.opalj.br.instructions.INVOKESTATIC instruction.
- Definition Classes
- ProjectLike
- def statistics: Map[String, Int]
Some basic statistics about this project.
Some basic statistics about this project.
((Re)Calculated on-demand.)
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toJavaMap(): HashMap[ObjectType, ClassFile]
Converts this project abstraction into a standard Java
HashMap
.Converts this project abstraction into a standard Java
HashMap
.- Note
This method is intended to be used by Java projects that want to interact with OPAL.
- def toString(): String
- Definition Classes
- Project → AnyRef → Any
- def updateProjectInformationKeyInitializationData[T <: AnyRef, I <: AnyRef](key: ProjectInformationKey[T, I])(info: (Option[I]) => I): I
Updates project information key specific initialization object.
Updates project information key specific initialization object. If an object is already registered, that object will be given to
info
.- Note
Initialization data is discarded once the key is used.
- def virtualCall(callerType: ObjectType, declaringType: ReferenceType, name: String, descriptor: MethodDescriptor): Set[Method]
Returns the set of methods that may be called by an invokevirtual call, if the receiver type is unknown or effectively encompasses all subtypes it is recommended to use instanceCall.
Returns the set of methods that may be called by an invokevirtual call, if the receiver type is unknown or effectively encompasses all subtypes it is recommended to use instanceCall.
- Definition Classes
- ProjectLike
- Note
As in case of instance call, the returned method may have a different descriptor if we have a signature polymorphic call!
- def virtualCall(callerType: ObjectType, i: INVOKEVIRTUAL): Set[Method]
Convenience method; see
virtualCall(callerPackageName:String,declaringType:ReferenceType*
for details.Convenience method; see
virtualCall(callerPackageName:String,declaringType:ReferenceType*
for details.- Definition Classes
- ProjectLike
- final val virtualMethodsCount: Int
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])