Class/Object

org.opalj.br.analyses

Project

Related Docs: object Project | package analyses

Permalink

class Project[Source] extends ClassFileRepository

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.

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
ClassFileRepository, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Project
  2. ClassFileRepository
  3. AnyRef
  4. 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. val allClassFiles: Iterable[ClassFile]

    Permalink
  5. val allLibraryClassFiles: Iterable[ClassFile]

    Permalink
  6. val allProjectClassFiles: Iterable[ClassFile]

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

  8. val analysisMode: AnalysisMode

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

    Permalink
    Definition Classes
    Any
  10. 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.

  11. 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
  12. 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
  13. 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. (This method is defined for all ObjectTypes.)

    Definition Classes
    ProjectClassFileRepository
  14. 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.

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

    Permalink
  16. val classHierarchy: ClassHierarchy

    Permalink
  17. def clone(): AnyRef

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

    Permalink
  19. implicit val config: Config

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  22. 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.

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

    Permalink

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

  24. def fields(): Iterable[Field]

    Permalink

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

  25. final val fieldsCount: Int

    Permalink

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

  26. 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
  27. 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.

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

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

    Permalink
  30. 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.

  31. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  32. final def isInstanceOf[T0]: Boolean

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

    Permalink

    Returns true if the given type file belongs to the library part of the project.

    Returns true if the given type file belongs to the library part of the project. This is generally the case if no class file was loaded for the given type.

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

  35. val libraryClassFilesAreInterfacesOnly: Boolean

    Permalink

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

  36. val libraryClassFilesCount: Int

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

    Permalink
  38. val libraryFieldsCount: Int

    Permalink
  39. val libraryMethodsCount: Int

    Permalink
  40. def libraryPackages: Set[String]

    Permalink

    Returns the list of all library packages that contain at least one class.

    Returns the list 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.

  41. implicit 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
  42. 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.

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

    Permalink

    The set of all method names of the given types.

  44. def methods(): Iterable[Method]

    Permalink

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

  45. final val methodsCount: Int

    Permalink

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

  46. def methodsWithBody: Iterable[Method]

    Permalink
  47. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  50. 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.

  51. def packagesCount: Int

    Permalink

    Number of packages.

    Number of packages.

    Note

    The result is (re)calculated for each call.

  52. def parForeachClassFile[T](isInterrupted: () ⇒ Boolean = ...)(f: (ClassFile) ⇒ T): List[Throwable]

    Permalink
  53. def parForeachLibraryClassFile[T](isInterrupted: () ⇒ Boolean = ...)(f: (ClassFile) ⇒ T): List[Throwable]

    Permalink
  54. def parForeachMethodWithBody[T](isInterrupted: () ⇒ Boolean = ...)(f: Function[(Source, ClassFile, Method), T]): List[Throwable]

    Permalink

    Iterates over all methods with a body in parallel.

    Iterates over all methods with a body in parallel.

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

  55. def parForeachProjectClassFile[T](isInterrupted: () ⇒ Boolean = ...)(f: (ClassFile) ⇒ T): List[Throwable]

    Permalink
  56. val projectClassFilesCount: Int

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

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

    Permalink

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

    Returns the number of (non-synthetic) source elements per method length (size in length of the method's code array). The number of class members of nested classes are also taken into consideration.

  59. val projectFieldsCount: Int

    Permalink
  60. val projectMethodsCount: Int

    Permalink
  61. def projectMethodsLengthDistribution: Map[Int, (Int, Set[Method])]

    Permalink

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

  62. def projectPackages: Set[String]

    Permalink

    Returns the list of all project packages that contain at least one class.

    Returns the list 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.

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

  64. 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. (This method is defined for all ObjectTypes.)

  65. def sourceElementsCount: Int

    Permalink

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

  66. def statistics: Map[String, Int]

    Permalink

    Some basic statistics about this project.

    Some basic statistics about this project.

    ((Re)Calculated on-demand.)

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

    Permalink
    Definition Classes
    AnyRef
  68. 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.

  69. def toString(): String

    Permalink
    Definition Classes
    Project → AnyRef → Any
  70. final def wait(): Unit

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

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

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

Inherited from ClassFileRepository

Inherited from AnyRef

Inherited from Any

Ungrouped