Package edu.umd.cs.findbugs.ba
Class MethodHash
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.MethodHash
-
- All Implemented Interfaces:
java.lang.Comparable<MethodHash>
public class MethodHash extends java.lang.Object implements java.lang.Comparable<MethodHash>
Compute a hash of the bytecode for given method. This can find methods which have not been changed other than accessing different constant pool entries.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
hash
private boolean
isStatic
static java.lang.String
METHOD_HASH_ELEMENT_NAME
private java.lang.String
methodName
private java.lang.String
methodSig
-
Constructor Summary
Constructors Constructor Description MethodHash()
Constructor.MethodHash(java.lang.String methodName, java.lang.String methodSig, boolean isStatic, byte[] hash)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
compareHashes(byte[] a, byte[] b)
int
compareTo(MethodHash other)
MethodHash
computeHash(org.apache.bcel.classfile.Method method)
Compute hash on given method.boolean
equals(java.lang.Object o)
byte[]
getMethodHash()
Get the computed method hash.java.lang.String
getMethodName()
java.lang.String
getMethodSig()
int
hashCode()
boolean
isSameHash(MethodHash other)
Return whether or not this method hash has the same value as the one given.boolean
isStatic()
private static int
toUnsigned(byte b)
Convert a byte to an unsigned int.
-
-
-
Field Detail
-
METHOD_HASH_ELEMENT_NAME
public static final java.lang.String METHOD_HASH_ELEMENT_NAME
- See Also:
- Constant Field Values
-
hash
private byte[] hash
-
methodName
private java.lang.String methodName
-
methodSig
private java.lang.String methodSig
-
isStatic
private boolean isStatic
-
-
Constructor Detail
-
MethodHash
public MethodHash()
Constructor. computeHash(Method) must be used to initialize the contents.
-
MethodHash
public MethodHash(java.lang.String methodName, java.lang.String methodSig, boolean isStatic, byte[] hash)
Constructor.- Parameters:
methodName
- method namemethodSig
- method signatureisStatic
- true if the method is static, false if nothash
- the pre-computed hash
-
-
Method Detail
-
getMethodName
public java.lang.String getMethodName()
- Returns:
- Returns the method name.
-
getMethodSig
public java.lang.String getMethodSig()
- Returns:
- Returns the method signature.
-
isStatic
public boolean isStatic()
- Returns:
- Returns whether the method is static.
-
getMethodHash
public byte[] getMethodHash()
Get the computed method hash.- Returns:
- the method hash
-
computeHash
public MethodHash computeHash(org.apache.bcel.classfile.Method method)
Compute hash on given method.- Parameters:
method
- the method- Returns:
- this object
-
isSameHash
public boolean isSameHash(MethodHash other)
Return whether or not this method hash has the same value as the one given.- Parameters:
other
- another MethodHash- Returns:
- true if the hash values are the same, false if not
-
compareTo
public int compareTo(MethodHash other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<MethodHash>
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareHashes
public static int compareHashes(byte[] a, byte[] b)
-
toUnsigned
private static int toUnsigned(byte b)
Convert a byte to an unsigned int.- Parameters:
b
- a byte value- Returns:
- the unsigned integer value of the byte
-
-