Class CodeLocation

  • All Implemented Interfaces:
    java.lang.Comparable<Location>

    public class CodeLocation
    extends Location
    Represents a unique location in the bytecode. It comprises the Clazz and Member where it is contained, the offset therein and the corresponding line number in the source file (Location.UNKNOWN_LINE if it is unknown). Consider the following pseudo-bytecode example which contains code location comments:
    
     public class Test
     {
         // class "Test", member "field", line 3, offset 0
         public String field;
    
         public String toString()
         {
             // class "Test", member "toString", line 6, offset 0
             aload_0
             // class "Test", member "toString", line 6, offset 1
             getfield #1 &lt;Test.field : Ljava/lang/String;&gt;
             // class "Test", member "toString", line 6, offset 4
             areturn
         }
     }
    
     
    • Inside methods: Like each location, instructions inside methods have a line number. But as there may be several expressions on the same line, to correctly identify each instruction we also need their bytecode offset. E.g. the getfield instruction inside toString() has the offset 1.
    • Fields: In this case Test#field. A field location has a line number (3 in this example) but no offset, as this concept is only applicable to methods.
    • Field Detail

      • clazz

        public final Clazz clazz
      • member

        public final Member member
      • offset

        public final int offset
      • signature

        public final Signature signature
    • Constructor Detail

      • CodeLocation

        public CodeLocation​(Clazz clazz,
                            Member member,
                            int offset,
                            int line)
    • Method Detail

      • getExternalClassName

        public java.lang.String getExternalClassName()
      • getMemberName

        public java.lang.String getMemberName()
      • getName

        public java.lang.String getName()
        Description copied from class: Location
        Returns the name of the location, e.g., the signature of a CodeLocation, or the filename of a FileLocation
        Specified by:
        getName in class Location
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(Location o)