Trait

org.opalj.br

Signature

Related Doc: package br

Permalink

sealed trait Signature extends SignatureElement with Attribute

An attribute-level signature as defined in the JVM specification.

To match Signature objects the predefined matchers/extractors can be used. * @example

Example 1

interface Processor extends Function<Object, Void> { /*empty*/ }

ClassSignature: Ljava/lang/Object;Ljava/util/function/Function<Ljava/lang/Object;Ljava/lang/Void;>;

ClassSignature(
  typeParameters=List(),
  superClass=ClassTypeSignature(Some(java/lang/),SimpleClassTypeSignature(Object,List()),List()),
  superInterfaces=List(
      ClassTypeSignature(
          Some(java/util/function/),
          SimpleClassTypeSignature(Function,
                List(ProperTypeArgument(
                       None,
                       ClassTypeSignature(
                          Some(java/lang/),
                          SimpleClassTypeSignature(Object,List()),
                          List())),
                   ProperTypeArgument(
                      None,
                      ClassTypeSignature(
                          Some(java/lang/),
                          SimpleClassTypeSignature(Void,List()),
                          List())))),
          List())))

Example 2

interface Col<C> { /*empty*/ }

ClassSignature: <C:Ljava/lang/Object;>Ljava/lang/Object;

ClassSignature(
    typeParameters=
        List(
            FormalTypeParameter(
                C,
                Some(ClassTypeSignature(
                        Some(java/lang/),SimpleClassTypeSignature(Object,List()),List())),
                List())),
     superClass=ClassTypeSignature(
            Some(java/lang/),SimpleClassTypeSignature(Object,List()),List()),
     superInterfaces=List())

Example 3

interface ColObject extends Col<Object> { /*empty*/ }

ClassSignature: Ljava/lang/Object;LCol<Ljava/lang/Object;>;

ClassSignature(
    typeParameters=List(),
    superClass=ClassTypeSignature(Some(java/lang/),SimpleClassTypeSignature(Object,List()),List()),
    superInterfaces=List(
            ClassTypeSignature(
                None,
                SimpleClassTypeSignature(
                    Col,
                    List(ProperTypeArgument(
                            variance=None,
                            signature=ClassTypeSignature(Some(java/lang/),SimpleClassTypeSignature(Object,List()),List()))
                 )),
                 List())))

Example 4

interface ColError<E extends Error> extends Col<E>{/*empty*/}

ClassSignature: <E:Ljava/lang/Error;>Ljava/lang/Object;LCol<TE;>;

ClassSignature(
    typeParameters=List(
            FormalTypeParameter(
                E,
                Some(ClassTypeSignature(Some(java/lang/),SimpleClassTypeSignature(Error,List()),List())),List())),
    superClass=ClassTypeSignature(Some(java/lang/),SimpleClassTypeSignature(Object,List()),List()),
    superInterfaces=List(
            ClassTypeSignature(
                None,
                SimpleClassTypeSignature(
                    Col,
                    List(ProperTypeArgument(variance=None,signature=TypeVariableSignature(E)))),
                List())))

Example 5

class Use {
  // The following fields all have "ClassTypeSignatures"
  Col<?> ce = null; // Signature: LCol<*>;
  Col<Object> co = null; // Signature: LCol;
  Col<? super Serializable> cs = null; // Signature: LCol<-Ljava/io/Serializable;>;
  Col<? extends Comparable<?>> cc = null; // Signature: LCol<+Ljava/lang/Comparable<*>;>;

  MyCol<java.util.List<Object>> mco = new MyCol<>();
  MyCol<java.util.List<Object>>.MyInnerCol<Comparable<java.util.List<Object>>> mico = this.mco.new MyInnerCol<Comparable<java.util.List<Object>>>();
  // Signature: LMyCol;>.MyInnerCol;>;>;
}

AST of mico:

ClassSignature(
    typeParameters=List(),
    superClass=ClassTypeSignature(
            None,
            SimpleClassTypeSignature(
                MyCol,
                List(ProperTypeArgument(
                        variance=None,
                        signature=ClassTypeSignature(
                                Some(java/util/),
                                SimpleClassTypeSignature(
                                    List,
                                    List(ProperTypeArgument(
                                            variance=None,
                                            signature=ClassTypeSignature(
                                                    Some(java/lang/),
                                                    SimpleClassTypeSignature(Object,List()),
                                                    List())))),
                                 List())))),
            /*suffic=*/List(SimpleClassTypeSignature(
                    MyInnerCol,
                    List(ProperTypeArgument(
                            variance=None,
                            signature=ClassTypeSignature(
                                Some(java/lang/),
                                SimpleClassTypeSignature(
                                    Comparable,
                                    List(ProperTypeArgument(
                                            variance=None,
                                            signature=ClassTypeSignature(
                                                    Some(java/util/),
                                                    SimpleClassTypeSignature(
                                                        List,
                                                        List(ProperTypeArgument(
                                                                variance=None,
                                                                signature=ClassTypeSignature(
                                                                        Some(java/lang/),
                                                                        SimpleClassTypeSignature(Object,List()),
                                                                        List())))),
                                                    List())))),
                                List())))))),
    superInterfaces=List())

Matching Signatures

Scala REPL:

val SignatureParser = org.opalj.br.reader.SignatureParser
val GenericType = org.opalj.br.GenericType
val SimpleGenericType = org.opalj.br.SimpleGenericType
val BasicClassTypeSignature = org.opalj.br.BasicClassTypeSignature

SignatureParser.parseClassSignature("Ljava/lang/Object;LCol;").superInterfacesSignature.head match { case BasicClassTypeSignature(ot) => ot.toJava; case _ => null}
// res: String = Col

SignatureParser.parseClassSignature("Ljava/lang/Object;LCol;").superInterfacesSignature.head match { case SimpleGenericType(bt,gt) => bt.toJava+"<"+gt.toJava+">"; case _ => null}
//res11: String = null

scala> SignatureParser.parseFieldTypeSignature("LCol;") match { case SimpleGenericType(bt,ta) => bt.toJava+"<"+ta+">"; case _ => null}
res1: String = Col<ObjectType(java/lang/Object)>

scala> SignatureParser.parseFieldTypeSignature("LCol;") match { case GenericType(bt,ta) => bt.toJava+"<"+ta+">"; case _ => null}
res2: String = Col<List(ProperTypeArgument(variance=None,signature=ClassTypeSignature(Some(java/lang/),SimpleClassTypeSignature(Object,List()),List())))>
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Signature
  2. Attribute
  3. SignatureElement
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def accept[T](sv: SignatureVisitor[T]): T

    Permalink
    Definition Classes
    SignatureElement
  2. abstract def kindId: Int

    Permalink

    Returns the unique ID that identifies this kind of attribute (Signature, LineNumberTable,...)

    Returns the unique ID that identifies this kind of attribute (Signature, LineNumberTable,...)

    This id can then be used in a switch statement to efficiently identify the attribute.

    (attribute.id : @scala.annotation.switch) match {
         case Signature.Id => ...
    }

    Associating Unique Id

    The unique ids are manually associated with the attributes. The attributes use the following IDs:

    • (-1 Unknown Attribute)
    • 1-5 The ConstantValue Attribute
    • 6 The Code Attribute
    • 7 The StackMapTable Attribute
    • 8 The Exceptions Attribute
    • 9 The InnerClasses Attribute
    • 10 The EnclosingMethod Attribute
    • 11 The Synthetic Attribute
    • 12-16 The Signature Attribute
    • 17 The SourceFile Attribute
    • 18 The SourceDebugExtension Attribute
    • 19 The LineNumberTable Attribute
    • 20 The LocalVariableTable Attribute
    • 21 The LocalVariableTypeTable Attribute
    • 22 The Deprecated Attribute
    • 23 The RuntimeVisibleAnnotations Attribute
    • 24 The RuntimeInvisibleAnnotations Attribute
    • 25 The RuntimeVisibleParameterAnnotations Attribute
    • 26 The RuntimeInvisibleParameterAnnotations Attribute
    • 27 The RuntimeVisibleTypeAnnotations Attribute
    • 28 The RuntimeInvisibleTypeAnnotations Attribute
    • 29-41 The AnnotationDefault Attribute
    • 42 The BootstrapMethods Attribute
    • 43 The MethodParameters Attribute
    • 1001 OPAL's VirtualTypeFlag Attribute
    • 1002 OPAL's SynthesizedClassFiles Attribute
    Definition Classes
    Attribute
  3. abstract def toJVMSignature: String

    Permalink

    Converts this signature into its JVM representation.

    Converts this signature into its JVM representation. (See the JVM 5 or later specification for further details.)

    Definition Classes
    SignatureElement

Concrete 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 def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

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

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  16. def toString(): String

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

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

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

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

Inherited from Attribute

Inherited from SignatureElement

Inherited from AnyRef

Inherited from Any

Ungrouped