Class 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.
    Author:
    David Hovemeyer
    • Field Detail

      • METHOD_HASH_ELEMENT_NAME

        public static final java.lang.String METHOD_HASH_ELEMENT_NAME
        See Also:
        Constant Field Values
    • 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 name
        methodSig - method signature
        isStatic - true if the method is static, false if not
        hash - 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 interface java.lang.Comparable<MethodHash>
      • 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
      • compareHashes

        public static int compareHashes​(byte[] a,
                                        byte[] b)