Packages

final class ClassFile extends ConcreteSourceElement

Represents a single class file which either defines a class type or an interface type. (Annotation types are also interface types and Enums are class types.)

Source
ClassFile.scala
Note

Equality of ClassFile objects is reference based and a class file's hash code is the same as the underlying ObjectType's hash code; i.e., ' thisType's hash code.

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ClassFile
  2. ConcreteSourceElement
  3. SourceElement
  4. CommonSourceElementAttributes
  5. CommonAttributes
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def _UNSAFE_addMethod(methodTemplate: MethodTemplate): ClassFile

    Creates a new class file object with the given method.

    Creates a new class file object with the given method.

    This class file must not contain a method with the same name and descriptor!

    The old class file object must not be used after this call; if this cannot be guaranteed copy has to be used; otherwise the back-references (field -> class file and method -> class file) are broken!

    Note

    This method is primarily intended to be used to perform load-time transformations!

  5. def _UNSAFE_replaceAttributes(newAttributes: Attributes): ClassFile

    Creates a new class file object which has the specified attributes.

    Creates a new class file object which has the specified attributes.

    The old class file object must not be used after this call; if this cannot be guaranteed copy has to be used; otherwise the back-references (field -> class file and method -> class file) are broken!

    Note

    This method is primarily intended to be used to perform load-time transformations!

  6. def _UNSAFE_replaceMethod(oldMethod: Method, newMethod: MethodTemplate): ClassFile.this.type

    Creates a new class file object where the method oldMethod is replaced by the newMethod.

    Creates a new class file object where the method oldMethod is replaced by the newMethod. Hence, the old method must be defined by this class file!

    Both methods have to have the same name and descriptor!

    The old class file object must not be used after this call; if this cannot be guaranteed copy has to be used; otherwise the back-references (field -> class file and method -> class file) are broken!

    Note

    This method is primarily intended to be used to perform load-time transformations!

  7. val accessFlags: Int
    Definition Classes
    ClassFileConcreteSourceElement
  8. def annotations: Annotations

    The list of all annotations.

    The list of all annotations. In general, if a specific annotation is searched for the method runtimeVisibleAnnotations or runtimeInvisibleAnnotations should be used.

    Definition Classes
    CommonSourceElementAttributes
  9. def asClassFile: ClassFile.this.type
    Definition Classes
    ClassFileSourceElement
  10. def asField: Field
    Definition Classes
    SourceElement
  11. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  12. def asMethod: Method
    Definition Classes
    SourceElement
  13. def asVirtualClass: VirtualClass
  14. val attributes: Attributes
    Definition Classes
    ClassFileCommonAttributes
  15. def bootstrapMethodTable: Option[BootstrapMethodTable]

    Returns this class file's bootstrap method table.

    Returns this class file's bootstrap method table.

    Note

    A class file's bootstrap method table may be removed at load time if the corresponding org.opalj.br.instructions.INVOKEDYNAMIC instructions are rewritten.

  16. def classSignature: Option[ClassSignature]

    Each class file optionally defines a class signature.

  17. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  18. def compareAttributes(other: Attributes, config: SimilarityTestConfiguration): Option[AnyRef]

    Compares this element's attributes with the given one.

    Compares this element's attributes with the given one.

    returns

    None, if both attribute lists are similar; Some(<description of the difference>) otherwise.

    Attributes
    protected[this]
    Definition Classes
    CommonAttributes
  19. def constructors: Iterator[Method]

    All constructors/instance initialization methods (<init>) defined by this class.

    All constructors/instance initialization methods (<init>) defined by this class.

    (This does not include the static initializer.)

  20. def copy(version: UShortPair = this.version, accessFlags: Int = this.accessFlags, thisType: ObjectType = this.thisType, superclassType: Option[ObjectType] = this.superclassType, interfaceTypes: ObjectTypes = this.interfaceTypes, fields: FieldTemplates = this.fields.map[FieldTemplate](f => f.copy()), methods: MethodTemplates = this.methods.map[MethodTemplate](m => m.copy()), attributes: Attributes = this.attributes): ClassFile

    Creates a deep copy of this class file object which also copies the methods and fields.

    Creates a deep copy of this class file object which also copies the methods and fields.

    Note

    If the requirements of unsafeReplaceMethod are met you should use that method!

  21. def enclosingMethod: Option[EnclosingMethod]
  22. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. def equals(other: Any): Boolean
    Definition Classes
    ClassFile → AnyRef → Any
  24. val fields: Fields
  25. final def findDirectlyOverridingMethod(packageName: String, method: Method): Result[Method]
  26. def findDirectlyOverridingMethod(packageName: String, visibility: Option[VisibilityModifier], name: String, descriptor: MethodDescriptor): Result[Method]

    Returns the method which directly overrides a method with the given properties.

    Returns the method which directly overrides a method with the given properties. The result is Success(<Method>) if we can find a method; Empty if no method can be found and Failure if a method is found which supposedly overrides the specified method, but which is less visible.

    Note

    This method is only defined for proper virtual methods. I.e., asking for overridings of a private methods is not supported.

  27. def findDissimilarity(other: ClassFile, config: SimilarityTestConfiguration = CompareAllConfiguration): Option[AnyRef]

    Compares this class file with the given one; returns (the first) differences if any.

    Compares this class file with the given one; returns (the first) differences if any. The comparison tries to be stable in the presence of difference that are not runtime relevant. For example, the precise structure of the constant pool is completely irrelevant. Additionally, some variance in the bytecode (e.g., bipush(2) vs iconst_2) is generally irrelevant and also the order in which Attributes are found.

    The degree to which the two class files have to be similar can be configured using a SimilarityTestConfiguration object. By default, all parts will be compared and have to be equal except of irrelevant differences. The default (CompareAllConfiguration) compares all parts.

    returns

    None if this class file and the other are equal - i.e., if both effectively implement the same class.

  28. def findField(name: String, fieldType: FieldType): Option[Field]

    Returns the field with the given name and type.

  29. def findField(name: String): List[Field]

    Returns the field with the given name, if any.

    Returns the field with the given name, if any.

    Note

    The complexity is O(log2 n); this algorithm uses binary search.

  30. def findMethod(name: String, descriptor: MethodDescriptor, matcher: AccessFlagsMatcher): Option[Method]
  31. def findMethod(name: String, descriptor: MethodDescriptor): Option[Method]

    Returns the method with the given name and descriptor that is declared by this class file.

    Returns the method with the given name and descriptor that is declared by this class file.

    Note

    The complexity is O(log2 n); this algorithm uses a binary search algorithm.

  32. def findMethod(name: String): List[Method]

    Returns the methods (including constructors and static initializers) with the given name, if any.

    Returns the methods (including constructors and static initializers) with the given name, if any.

    Note

    The complexity is O(log2 n); this algorithm uses binary search.

  33. def foreachNestedClass(f: (ClassFile) => Unit)(implicit classFileRepository: ClassFileRepository): Unit

    Iterates over all direct and indirect nested classes of this class file.

    Iterates over all direct and indirect nested classes of this class file.

    Example:
    1. To collect all nested types:

      var allNestedTypes: Set[ObjectType] = Set.empty
      foreachNestedClasses(innerclassesProject, { nc => allNestedTypes += nc.thisType })
  34. final def foreachTypeAnnotation[U](f: (TypeAnnotation) => U): Unit
    Definition Classes
    CommonAttributes
  35. def fqn: String

    The fully qualified name of the type defined by this class file.

  36. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  37. def hasDefaultConstructor: Boolean

    Returns true if this class defines a so-called default constructor.

    Returns true if this class defines a so-called default constructor. A default constructor needs to be present, e.g., when the class is serializable.

    The default constructor is the constructor that takes no parameters.

    Note

    The result is recomputed.

  38. def hasFlags(accessFlags: Int): Boolean
    Definition Classes
    ConcreteSourceElement
  39. def hashCode(): Int

    This class file's hasCode.

    This class file's hasCode. The hashCode is (by purpose) identical to the id of the ObjectType it implements.

    Definition Classes
    ClassFile → AnyRef → Any
  40. def id: Int

    The unique id associated with the type defined by this class file.

  41. def innerClasses: Option[InnerClasses]

    Returns the inner classes attribute, if defined.

    Returns the inner classes attribute, if defined.

    Note

    The inner classes attribute contains (for inner classes) also a reference to its outer class. Furthermore, it contains references to other inner classes that are not an inner class of this class. If you are just interested in the inner classes of this class, use the method nested classes.

    See also

    nestedClasses

  42. def instanceMethods: Iterator[Method]

    All defined instance methods.

    All defined instance methods. I.e., all methods that are not static, constructors, or static initializers.

  43. val interfaceTypes: ObjectTypes
  44. def isAbstract: Boolean
  45. def isAnnotationDeclaration: Boolean
  46. def isAnonymousInnerClass: Boolean

    Returns true if this class file defines an anonymous inner class.

    Returns true if this class file defines an anonymous inner class.

    This method relies on the inner classes attribute to identify anonymous inner classes.

  47. def isClass: Boolean
    Definition Classes
    ClassFileSourceElement
  48. def isClassDeclaration: Boolean
  49. def isDeprecated: Boolean

    Returns true if this (field, method, class) declaration is declared as deprecated.

    Returns true if this (field, method, class) declaration is declared as deprecated.

    Note

    The deprecated attribute is always set by the Java compiler when either the deprecated annotation or the JavaDoc tag is used.

    Definition Classes
    CommonSourceElementAttributes
  50. def isEffectivelyFinal: Boolean

    Returns true if the class is final or if it only defines private constructors and it is therefore not possible to inherit from this class.

    Returns true if the class is final or if it only defines private constructors and it is therefore not possible to inherit from this class.

    An abstract type (abstract classes and interfaces) is never effectively final.

  51. def isEnumDeclaration: Boolean
  52. def isField: Boolean
    Definition Classes
    SourceElement
  53. def isFinal: Boolean
  54. def isInnerClass: Boolean
  55. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  56. def isInterfaceDeclaration: Boolean

    Returns true if this class file represents an interface.

    Returns true if this class file represents an interface.

    Note

    From the JVM point-of-view annotations are also interfaces!

    See also

    org.opalj.br.analyses.Project to determine if this interface declaration is a functional interface.

  57. def isMethod: Boolean
    Definition Classes
    SourceElement
  58. def isModuleDeclaration: Boolean
  59. def isPackageVisible: Boolean

    true if the class file has package visibility.

    true if the class file has package visibility. If false the method isPublic will return true.

    Note

    A class file cannot have private or protected visibility.

  60. def isPublic: Boolean

    true if the class file has public visibility.

    true if the class file has public visibility. If false the method isPackageVisible will return true.

    Note

    There is no private or protected visibility.

  61. def isSynthetic: Boolean

    True if this element was created by the compiler and the attribute Synthetic is present.

    True if this element was created by the compiler and the attribute Synthetic is present. Compilers are, however, free to use the attribute or the corresponding access flag.

    Definition Classes
    CommonSourceElementAttributes
  62. def isVirtual: Boolean
    Definition Classes
    SourceElement
  63. def isVirtualType: Boolean

    Returns true if this class file has no direct representation in the source code.

    Returns true if this class file has no direct representation in the source code.

    See also

    VirtualTypeFlag for further information.

  64. def jdkVersion: String
  65. def majorVersion: UShort
  66. def methodBodies: Iterator[Code]
  67. val methods: Methods
  68. def methodsWithBody: Iterator[Method]
  69. def minorVersion: UShort
  70. def module: Option[Module]

    Returns Java 9's module attribute if defined.

  71. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  72. def nestedClasses(implicit classFileRepository: ClassFileRepository): Seq[ObjectType]

    Returns the set of all immediate nested classes of this class.

    Returns the set of all immediate nested classes of this class. I.e., returns those nested classes that are not defined in the scope of a nested class of this class.

  73. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  74. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  75. def outerType: Option[(ObjectType, Int)]

    Each class has at most one explicit, direct outer type.

    Each class has at most one explicit, direct outer type. Note that a local class (a class defined in the scope of a method) or an anonymous class do not specify an outer type.

    returns

    The object type of the outer type as well as the access flags of this inner class.

  76. def runtimeInvisibleAnnotations: Annotations
  77. def runtimeInvisibleTypeAnnotations: TypeAnnotations
    Definition Classes
    CommonAttributes
  78. def runtimeVisibleAnnotations: Annotations
  79. def runtimeVisibleTypeAnnotations: TypeAnnotations
    Definition Classes
    CommonAttributes
  80. def similar(other: ClassFile, config: SimilarityTestConfiguration = CompareAllConfiguration): Boolean

    Compares this class file with the given one to check if both define the same class modulo those parts which are not considered relevant.

    Compares this class file with the given one to check if both define the same class modulo those parts which are not considered relevant.

    config

    Configures which parts of the class files should be compared.

    See also

    findDissimilarity for further information.

  81. def sourceDebugExtension: Option[Array[Byte]]

    The SourceDebugExtension attribute is an optional attribute [...].

    The SourceDebugExtension attribute is an optional attribute [...]. There can be at most one SourceDebugExtension attribute. The data (which is modified UTF8 String may, however, not be representable using a String object (see the spec. for further details.)

    The returned Array must not be mutated.

  82. def sourceFile: Option[String]

    The SourceFile attribute is an optional attribute [...].

    The SourceFile attribute is an optional attribute [...]. There can be at most one SourceFile attribute.

  83. def staticInitializer: Option[Method]

    The static initializer of this class.

    The static initializer of this class.

    Note

    The way how the static initializer is identified has changed with Java 7. In a class file whose version number is 51.0 or above, the method must have its ACC_STATIC flag set. Other methods named <clinit> in a class file are of no consequence.

  84. val superclassType: Option[ObjectType]
  85. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  86. def synthesizedClassFiles: Option[SynthesizedClassFiles]

    Returns OPAL's SynthesizedClassFiles attribute if it is defined.

  87. val thisType: ObjectType
  88. def toString(): String
    Definition Classes
    ClassFile → AnyRef → Any
  89. val version: UShortPair
  90. def visibilityModifier: Option[VisibilityModifier]
    Definition Classes
    ConcreteSourceElement
  91. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  92. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  93. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from ConcreteSourceElement

Inherited from SourceElement

Inherited from CommonAttributes

Inherited from AnyRef

Inherited from Any

Ungrouped