Package edu.umd.cs.findbugs.ba
Class Location
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.Location
-
- All Implemented Interfaces:
java.lang.Comparable<Location>
public class Location extends java.lang.Object implements java.lang.Comparable<Location>
A class representing a location in the CFG for a method. Essentially, it represents a static instruction, with the important caveat that CFGs have inlined JSR subroutines, meaning that a single InstructionHandle in a CFG may represent several static locations. To this end, a Location is comprised of both an InstructionHandle and the BasicBlock that contains it.Location objects may be compared with each other using the equals() method, and may be used as keys in tree and hash maps and sets. Note that it is only valid to compare Locations produced from the same CFG.
- Author:
- David Hovemeyer
- See Also:
CFG
-
-
Constructor Summary
Constructors Constructor Description Location(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Location other)booleanequals(java.lang.Object o)BasicBlockgetBasicBlock()Get the basic block.static LocationgetFirstLocation(BasicBlock basicBlock)org.apache.bcel.generic.InstructionHandlegetHandle()Get the instruction handle.static LocationgetLastLocation(BasicBlock basicBlock)inthashCode()booleanisFirstInstructionInBasicBlock()Return whether or not the Location is positioned at the first instruction in the basic block.booleanisLastInstructionInBasicBlock()Return whether or not the Location is positioned at the last instruction in the basic block.java.lang.StringtoCompactString()java.lang.StringtoString()
-
-
-
Constructor Detail
-
Location
public Location(@Nonnull org.apache.bcel.generic.InstructionHandle handle, @Nonnull BasicBlock basicBlock)Constructor.- Parameters:
handle- the instructionbasicBlock- the basic block containing the instruction
-
-
Method Detail
-
getFirstLocation
public static Location getFirstLocation(@Nonnull BasicBlock basicBlock)
-
getLastLocation
public static Location getLastLocation(@Nonnull BasicBlock basicBlock)
-
getHandle
@Nonnull public org.apache.bcel.generic.InstructionHandle getHandle()
Get the instruction handle.
-
getBasicBlock
@Nonnull public BasicBlock getBasicBlock()
Get the basic block.
-
isFirstInstructionInBasicBlock
public boolean isFirstInstructionInBasicBlock()
Return whether or not the Location is positioned at the first instruction in the basic block.
-
isLastInstructionInBasicBlock
public boolean isLastInstructionInBasicBlock()
Return whether or not the Location is positioned at the last instruction in the basic block.
-
compareTo
public int compareTo(Location other)
- Specified by:
compareToin interfacejava.lang.Comparable<Location>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toCompactString
public java.lang.String toCompactString()
- Returns:
- a compact string of the form "bb:xx", where "bb" is the basic block number and "xx" is the bytecode offset
-
-