Class MethodSignature


  • public class MethodSignature
    extends Object
    A method's comparison fingerprints: bytecode hash, opcode sequence, and structural counters.
    • Constructor Detail

      • MethodSignature

        public MethodSignature​(String className,
                               String methodName,
                               String descriptor)
        Creates an empty signature identifying a method; fingerprints are filled by fromMethod.
        Parameters:
        className - the owning class name
        methodName - the method name
        descriptor - the method descriptor
    • Method Detail

      • fromMethod

        public static MethodSignature fromMethod​(MethodEntry method,
                                                 String className)
        Builds a signature from a method entry, analyzing its bytecode when present.
        Parameters:
        method - the method to fingerprint
        className - the owning class name
        Returns:
        the populated signature
      • compareExactBytecode

        public double compareExactBytecode​(MethodSignature other)
        Compares bytecode hashes for an exact match.
        Parameters:
        other - the signature to compare against
        Returns:
        1.0 on equal hashes, otherwise 0.0
      • compareOpcodeSequence

        public double compareOpcodeSequence​(MethodSignature other)
        Compares opcode sequences using longest common subsequence length.
        Parameters:
        other - the signature to compare against
        Returns:
        the LCS length over the longer sequence, in [0, 1]
      • compareStructural

        public double compareStructural​(MethodSignature other)
        Compares structural metrics: instruction, branch, and call count ratios.
        Parameters:
        other - the signature to compare against
        Returns:
        the average ratio in [0, 1], 0 if no metrics are comparable
      • getClassName

        public String getClassName()
        Returns:
        the class name
      • getMethodName

        public String getMethodName()
        Returns:
        the method name
      • getDescriptor

        public String getDescriptor()
        Returns:
        the descriptor
      • getBytecodeHash

        public byte[] getBytecodeHash()
        Returns:
        the bytecode hash
      • getOpcodeSequence

        public int[] getOpcodeSequence()
        Returns:
        the opcode sequence
      • getInstructionCount

        public int getInstructionCount()
        Returns:
        the instruction count
      • getMaxStack

        public int getMaxStack()
        Returns:
        the max stack
      • getMaxLocals

        public int getMaxLocals()
        Returns:
        the max locals
      • getLoopCount

        public int getLoopCount()
        Returns:
        the loop count
      • getBranchCount

        public int getBranchCount()
        Returns:
        the branch count
      • getCallCount

        public int getCallCount()
        Returns:
        the call count
      • getFieldAccessCount

        public int getFieldAccessCount()
        Returns:
        the field access count
      • getDisplayName

        public String getDisplayName()
        Returns:
        a short display string of simple class name and method name
      • getFullReference

        public String getFullReference()
        Returns:
        the full reference in class.name+descriptor form