Class/Object

org.opalj.br.analyses

Project

Related Docs: object Project | package analyses

Permalink

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:

  1. It is a container for ClassFiles.
  2. It directly gives access to the project's class hierarchy.
  3. 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 SourceElementsPropertyStoreKey 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 JRE = "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib"
val project = org.opalj.br.analyses.Project(new java.io.File(JRE))

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, a File, a String 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 Eclipse IResource's are used to identify the location of a resource (e.g., a source or class file.)

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Project
  2. ProjectLike
  3. ClassFileRepository
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final val MethodHandleClassFile: Option[ClassFile]

    Permalink

    The class file of java.lang.invoke.MethodHandle, if available.

    The class file of java.lang.invoke.MethodHandle, if available.

    Definition Classes
    ProjectProjectLike
  5. final val MethodHandleSubtypes: Set[ObjectType]

    Permalink

    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
    ProjectProjectLike
  6. final val ObjectClassFile: Option[ClassFile]

    Permalink

    The class file of java.lang.Object, if available.

    The class file of java.lang.Object, if available.

    Definition Classes
    ProjectProjectLike
  7. final val allClassFiles: Iterable[ClassFile]

    Permalink
  8. def allFields: Iterable[Field]

    Permalink

    All fields defined by this project as well as the visible fields defined by the libraries.

  9. final val allLibraryClassFiles: Iterable[ClassFile]

    Permalink
  10. def allMethods: Iterable[Method]

    Permalink

    All methods defined by this project as well as the visible methods defined by the libraries.

  11. def allMethodsWithBody: Iterable[Method]

    Permalink
  12. def allMethodsWithBodyWithContext: Iterable[MethodInfo[Source]]

    Permalink
  13. def allMethodsWithContext: Iterable[(Method, ClassFile)]

    Permalink

    Iterable of all methods along along with its defining class file.

  14. final val allProjectClassFiles: Iterable[ClassFile]

    Permalink
  15. def allSourceElements: Iterable[SourceElement]

    Permalink

    Returns a new Iterable over all source elements of the project.

    Returns a new Iterable over all source elements of the project. The set of all source elements consists of (in this order): all methods + all fields + all class files.

  16. final val analysisMode: AnalysisMode

    Permalink
    Definition Classes
    ProjectClassFileRepository
  17. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  18. def availableProjectInformation: List[AnyRef]

    Permalink

    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.

  19. def classFile(field: Field): ClassFile

    Permalink

    Returns the given field's class file.

    Returns the given field's class file. This method is only defined if the field was previously added to this project. (I.e., the class file which defines the field was added.)

    Definition Classes
    ProjectClassFileRepository
  20. def classFile(method: Method): ClassFile

    Permalink

    Returns the given method's class file.

    Returns the given method's class file. This method is only defined if the method was previously added to this project. (I.e., the class file which defines the method was added.)

    Definition Classes
    ProjectClassFileRepository
  21. def classFile(objectType: ObjectType): Option[ClassFile]

    Permalink

    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
    ProjectClassFileRepository
  22. final val classFilesCount: Int

    Permalink

    The number of classes (including inner and annoymous classes as well as interfaces, annotations, etc.) defined in libraries and in the analyzed project.

  23. def classFilesWithSources: Iterable[(ClassFile, Source)]

    Permalink
  24. final val classHierarchy: ClassHierarchy

    Permalink
    Definition Classes
    ProjectProjectLike
  25. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final val codeSize: Long

    Permalink
  27. implicit final val config: Config

    Permalink
  28. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  29. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  30. def extend(other: Project[Source]): Project[Source]

    Permalink

    Creates a new Project which also includes this as well as the other project's class files.

  31. def extend(projectClassFilesWithSources: Iterable[(ClassFile, Source)]): Project[Source]

    Permalink

    Creates a new Project which also includes the given class files.

  32. final val fieldsCount: Int

    Permalink

    The number of field defined in libraries and in the analyzed project.

  33. def finalize(): Unit

    Permalink

    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
  34. def findMaximallySpecificSuperinterfaceMethods(superinterfaceTypes: UIDSet[ObjectType], name: String, descriptor: MethodDescriptor, analyzedSuperinterfaceTypes: UIDSet[ObjectType]): (UIDSet[ObjectType], Set[Method])

    Permalink

    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
  35. def findMaximallySpecificSuperinterfaceMethods(superinterfaceType: ObjectType, name: String, descriptor: MethodDescriptor, analyzedSuperinterfaceTypes: UIDSet[ObjectType] = UIDSet.empty): (UIDSet[ObjectType], Set[Method])

    Permalink

    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.

  36. final lazy val functionalInterfaces: UIDSet[ObjectType]

    Permalink

    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!

  37. def get[T <: AnyRef](pik: ProjectInformationKey[T]): T

    Permalink

    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.

  38. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  39. def groupedClassFilesWithMethodsWithBody(groupsCount: Int): Array[Buffer[ClassFile]]

    Permalink

    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.

  40. def has[T <: AnyRef](pik: ProjectInformationKey[T]): Option[T]

    Permalink

    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 and None will be returned.

    See also

    ProjectInformationKey for further information.

  41. def hasVirtualMethod(objectType: ObjectType, method: Method): Answer

    Permalink

    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., returns true if a virtual method call, where the receiver type is known to have the given objectType, would lead to the invokation of the given method. The given method can be an inherited method, but it will never return Yes if the given method is overridden by objectType or a supertype of it which is a sub type of the declaring type of method.

    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.

  42. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  43. def instanceCall(callerType: ObjectType, receiverType: ReferenceType, name: String, descriptor: MethodDescriptor): Result[Method]

    Permalink

    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 when the runtime type, which is the receiver of the method call, is precisely known!

    This method supports default methods and signature polymorphic calls.

    callerType

    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
  44. final val instanceMethods: Map[ObjectType, ConstArray[MethodDeclarationContext]]

    Permalink

    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
    ProjectProjectLike
  45. def interfaceCall(declaringClass: ObjectType, name: String, descriptor: MethodDescriptor): Set[Method]

    Permalink

    Returns the methods that may be called by org.opalj.br.instructions.INVOKEINTERFACE if the precise runtime type is not known.

    Returns the methods that may be called by org.opalj.br.instructions.INVOKEINTERFACE if the precise runtime type is not known. (If the precise runtime type is known use instanceCall to get the target method.)

    Definition Classes
    ProjectLike
    Note

    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!

    ,

    Caching the result (in particular when the call graph is computed) is recommended as the computation is expensive.

  46. def interfaceCall(i: INVOKEINTERFACE): Set[Method]

    Permalink
    Definition Classes
    ProjectLike
  47. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  48. def isLibraryType(objectType: ObjectType): Boolean

    Permalink

    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.

  49. def isLibraryType(classFile: ClassFile): Boolean

    Permalink

    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.

  50. def isProjectType(objectType: ObjectType): Boolean

    Permalink

    Returns true iff the given type belongs to the project and not to a library.

  51. def isSignaturePolymorphic(definingClassType: ObjectType, method: Method): Boolean

    Permalink

    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 8 Spec. for details.)

    Definition Classes
    ProjectLike
  52. final val libraryClassFilesAreInterfacesOnly: Boolean

    Permalink

    If true then only the public interface of the methods of the library's classes is available.

  53. final val libraryClassFilesCount: Int

    Permalink
  54. def libraryClassFilesWithSources: Iterable[(ClassFile, Source)]

    Permalink
  55. final val libraryFieldsCount: Int

    Permalink
  56. final val libraryMethodsCount: Int

    Permalink
  57. def libraryPackages: Set[String]

    Permalink

    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 package java.lang is.

    Note

    This method's result is not cached.

  58. implicit final val logContext: LogContext

    Permalink

    The logging context associated with this project.

    The logging context associated with this project. Using the logging context after the project is no longer referenced (garbage collected) is not possible.

    Definition Classes
    ProjectClassFileRepository
  59. def lookupClassFiles(objectTypes: Traversable[ObjectType])(classFileFilter: (ClassFile) ⇒ Boolean): Traversable[ClassFile]

    Permalink

    Returns all available ClassFile objects for the given objectTypes that pass the given filter.

    Returns all available ClassFile objects for the given objectTypes that pass the given filter. ObjectTypes for which no ClassFile is available are ignored.

  60. def lookupImplementingMethods(receiverType: ObjectType, methodName: String, methodDescriptor: MethodDescriptor, classesFilter: (ObjectType) ⇒ Boolean): Set[Method]

    Permalink

    Returns all classes that implement the given method by searching all subclasses of receiverType for implementations of the given method and also considering the superclasses of the receiverType up until the class (not interface) that defines the respective method.

    Returns all classes that implement the given method by searching all subclasses of receiverType for implementations of the given method and also considering the superclasses of the receiverType up until the class (not interface) that defines the respective method.

    receiverType

    An upper bound of the runtime type of some value. If the type is known to be precise (i.e., it is no approximation of the runtime type) then it is far more meaningful to directly call lookupMethodDefinition.

    methodName

    The name of the method.

    methodDescriptor

    The method's descriptor.

    classesFilter

    A function that returns true, if the runtime type of the receiverType may be of the type defined by the given object type. For example, if you analyze a project and perform a lookup of all methods that implement the method toString, then this set would probably be very large. But, if you know that only instances of the class (e.g.) ArrayList have been created so far (up to the point in your analysis where you call this method), it is meaningful to sort out all other classes (such as Vector).

    Definition Classes
    ProjectLike
  61. def lookupMethodDefinition(receiverType: ObjectType, methodName: String, methodDescriptor: MethodDescriptor): Option[Method]

    Permalink

    Looks up the class file and method which actually defines the method that is referred to by the given receiver type, method name and method descriptor.

    Looks up the class file and method which actually defines the method that is referred to by the given receiver type, method name and method descriptor. Given that we are searching for method definitions the search is limited to the superclasses of the class of the given receiver type.

    This method does not take visibility modifiers or the static modifier into account. If necessary, such checks need to be done by the caller.

    This method supports resolution of signature polymorphic methods (in this case however, it needs to be checked that the respective invoke instruction is an invokevirtual instruction.)

    returns

    Some(Method) if the method is found. None if the method is not found. This can basically happen under two circumstances: First, not all class files referred to/used by the project are (yet) analyzed; i.e., we do not have all class files belonging to this project. Second, the analyzed class files do not belong together (they either belong to different projects or to incompatible versions of the same project.) To get the method's defining class file use the project's respective method.

    Definition Classes
    ProjectLike
    Note

    In case that you analyze static source code dependencies and if an invoke instruction refers to a method that is not defined by the receiver's class, then it might be more meaningful to still create a dependency to the receiver's class than to look up the actual definition in one of the receiver's super classes.

  62. def lookupMethodDefinition(invocation: MethodInvocationInstruction): Option[Method]

    Permalink

    Definition Classes
    ProjectLike
    See also

    lookupMethodDefinition(ObjectType,String,MethodDescriptor,ClassFileRepository)

  63. def lookupMethodInInterface(classFile: ClassFile, methodName: String, methodDescriptor: MethodDescriptor): Option[Method]

    Permalink
    Definition Classes
    ProjectLike
  64. def lookupMethodInSuperinterfaces(classFile: ClassFile, methodName: String, methodDescriptor: MethodDescriptor): Option[Method]

    Permalink
    Definition Classes
    ProjectLike
  65. def lookupVirtualMethod(callingContextType: ObjectType, receiverType: ObjectType, name: String, descriptor: MethodDescriptor): Result[MethodDeclarationContext]

    Permalink

    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. The callingContextType 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 not complete. Hence, Empty$ may be indicative of an inconsistent project, if this lookup is expected to succeed.

    Definition Classes
    ProjectLike
    Note

    It supports the lookup of polymorphic methods.

    ,

    This method uses the pre-computed information about instance methods and, therefore, does not require a type hierarchy based lookup.

  66. def methodNames(objectTypes: Traversable[ObjectType]): Set[String]

    Permalink

    The set of all method names of the given types.

  67. final val methodsCount: Int

    Permalink

    The number of methods defined in libraries and in the analyzed project.

  68. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  69. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  70. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  71. def overriddenBy(m: Method): Set[Method]

    Permalink

    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 method m 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
  72. final val overridingMethods: Map[Method, Set[Method]]

    Permalink

    Returns for a given virtual method the set of all non-abstract virtual methods which overrides it.

    Returns for a given virtual method the set of all non-abstract virtual methods which overrides it.

    This method takes the visibility of the methods and the defining context into consideration.

    Definition Classes
    ProjectProjectLike
    Note

    The map only contains those methods which have at least one concrete implementation.

    See also

    Method.isVirtualMethodDeclaration for further details.

  73. def packages: Set[String]

    Permalink

    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 package java.lang is.

    Note

    This method's result is not cached.

  74. def packagesCount: Int

    Permalink

    Number of packages.

    Number of packages.

    Note

    The result is (re)calculated for each call.

  75. def parForeachClassFile[T](isInterrupted: () ⇒ Boolean = defaultIsInterrupted)(f: (ClassFile) ⇒ T): Iterable[Throwable]

    Permalink
  76. def parForeachLibraryClassFile[T](isInterrupted: () ⇒ Boolean = defaultIsInterrupted)(f: (ClassFile) ⇒ T): Iterable[Throwable]

    Permalink
  77. def parForeachMethodWithBody[T](isInterrupted: () ⇒ Boolean = defaultIsInterrupted, parallelizationLevel: Int = NumberOfThreadsForCPUBoundTasks)(f: (MethodInfo[Source]) ⇒ T): Iterable[Throwable]

    Permalink

    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).

  78. def parForeachProjectClassFile[T](isInterrupted: () ⇒ Boolean = defaultIsInterrupted)(f: (ClassFile) ⇒ T): Iterable[Throwable]

    Permalink
  79. final val projectClassFilesCount: Int

    Permalink
  80. def projectClassFilesWithSources: Iterable[(ClassFile, Source)]

    Permalink
  81. def projectClassMembersPerClassDistribution: Map[Int, (Int, Set[String])]

    Permalink

    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.

  82. final val projectFieldsCount: Int

    Permalink
  83. final val projectMethodsCount: Int

    Permalink
  84. def projectMethodsLengthDistribution: Map[Int, Set[Method]]

    Permalink

    Returns the (number of) (non-synthetic) methods per method length (size in length of the method's code array).

  85. def projectPackages: Set[String]

    Permalink

    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 package java.lang is.

    Note

    This method's result is not cached.

  86. def resolveClassMethodReference(receiverType: ObjectType, name: String, descriptor: MethodDescriptor): Result[Method]

    Permalink

    returns

    org.opalj.Success(method) if the method was found; Failure if the project is incomplete and the method could not be found; Empty if the method could not be found though the project is seemingly complete. I.e., if Empty is returned the analyzed code basis is most likely inconsistent.

    Definition Classes
    ProjectLike
  87. final def resolveFieldReference(fieldAccess: FieldAccess): Option[Field]

    Permalink

    Definition Classes
    ProjectLike
    See also

    resolveFieldReference(ObjectTypeString,FieldType):Option[Field]

  88. def resolveFieldReference(declaringClassFile: ClassFile, fieldName: String, fieldType: FieldType): Option[Field]

    Permalink
    Definition Classes
    ProjectLike
  89. def resolveFieldReference(declaringClassType: ObjectType, fieldName: String, fieldType: FieldType): Option[Field]

    Permalink

    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 with c's superinterfaces before the search is continued with c'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).

    declaringClassType

    The class (or a superclass thereof) that is expected to define the reference field.

    fieldName

    The name of the accessed field.

    fieldType

    The type of the accessed field (the field descriptor).

    returns

    The field that is referred to; if any. To get the defining ClassFile you can use the project.

    Definition Classes
    ProjectLike
    Note

    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.

    ,

    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 a LinkingException. Furthermore, if the field cannot be found, it is the responsibility of the caller to handle that situation.

  90. def resolveInterfaceMethodReference(i: INVOKEINTERFACE): Option[Method]

    Permalink
    Definition Classes
    ProjectLike
  91. def resolveInterfaceMethodReference(receiverType: ObjectType, name: String, descriptor: MethodDescriptor): Option[Method]

    Permalink
    Definition Classes
    ProjectLike
  92. def resolveMethodReference(i: INVOKEVIRTUAL): Option[Method]

    Permalink
    Definition Classes
    ProjectLike
  93. def resolveMethodReference(declaringClass: ReferenceType, name: String, descriptor: MethodDescriptor, forceLookupInSuperinterfacesOnFailure: Boolean = false): Option[Method]

    Permalink

    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 of invokevirtual and invokeinterface instructions. I.e., additional processing is necessary on the client side.

    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. (This setting is only relevant if the class hierarchy is not complete.)

    returns

    The resolved method Some(METHOD) or None. (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.

  94. def rootPackages: Map[String, String]

    Permalink

    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.

  95. def source(classFile: ClassFile): Option[Source]

    Permalink
  96. def source(objectType: ObjectType): Option[Source]

    Permalink

    Returns the source (for example, a File object or URL object) from which the class file was loaded that defines the given object type, if any.

    Returns the source (for example, a File object or URL object) from which the class file was loaded that defines the given object type, if any.

    objectType

    Some object type.

  97. def sourceElementsCount: Int

    Permalink

    The number of all source elements (fields, methods and class files).

  98. def specialCall(declaringClass: ObjectType, isInterface: Boolean, name: String, descriptor: MethodDescriptor): Result[Method]

    Permalink

    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 definitively incomplete and the method could not be found;
    • Empty if the method could not be found though the project is seemingly complete. I.e., if Empty is returned the analyzed code basis is most likely inconsistent.
    Definition Classes
    ProjectLike
    Note

    Virtual method call resolution is not necessary; the call target is either a constructor, a private method or a super method/constructor. However, in the last case it may be possible that we can't find the method because of an incomplete project. In that case the result will be Empty$. If the project is complete, but we can't find the class the result is Failure$; this is indicative of an inconsistent project.

  99. def specialCall(i: INVOKESPECIAL): Result[Method]

    Permalink
    Definition Classes
    ProjectLike
  100. def staticCall(declaringClass: ObjectType, isInterface: Boolean, name: String, descriptor: MethodDescriptor): Result[Method]

    Permalink

    Returns the method that will be called by the respective invokestatic call.

    Returns the method that will be called by the respective invokestatic call. (The client may require to perform additional checks such as validating the visibility!)

    returns

    org.opalj.Success (method) if the method was found; Failure if the project is incomplete and the method could not be found; Empty if the method could not be found though the project is seemingly complete. I.e., if Empty is returned the analyzed code basis is most likely inconsistent.

    Definition Classes
    ProjectLike
  101. def staticCall(i: INVOKESTATIC): Result[Method]

    Permalink

    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
  102. def statistics: Map[String, Int]

    Permalink

    Some basic statistics about this project.

    Some basic statistics about this project.

    ((Re)Calculated on-demand.)

  103. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  104. def toJavaMap(): HashMap[ObjectType, ClassFile]

    Permalink

    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.

  105. def toString(): String

    Permalink
    Definition Classes
    Project → AnyRef → Any
  106. def virtualCall(callerPackageName: String, declaringType: ReferenceType, name: String, descriptor: MethodDescriptor): Set[Method]

    Permalink

    Returns the set of methods that may be called by an invokevirtual call, if the return type is unknown.

    Returns the set of methods that may be called by an invokevirtual call, if the return type is unknown.

    Definition Classes
    ProjectLike
  107. def virtualCall(callerPackageName: String, i: INVOKEVIRTUAL): Set[Method]

    Permalink
    Definition Classes
    ProjectLike
  108. final val virtualMethodsCount: Int

    Permalink
  109. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  110. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  111. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from ProjectLike

Inherited from ClassFileRepository

Inherited from AnyRef

Inherited from Any

Ungrouped