Class Level0Features

  • All Implemented Interfaces:
    FeatureVector

    public class Level0Features
    extends Object
    implements FeatureVector
    Ultra-stable fingerprint features: normalized signature shape plus called, accessed, and instantiated targets.
    • Constructor Detail

      • Level0Features

        public Level0Features​(String returnType,
                              int parameterCount,
                              List<String> paramTypes,
                              int exceptionHandlerCount,
                              int monitorCount,
                              Set<String> externalCallTargets,
                              Set<String> fieldAccessTargets,
                              Set<String> instantiatedTypes)
        Creates a level-0 feature set, normalizing the types and copying the target sets in sorted order.
        Parameters:
        returnType - the return type descriptor
        parameterCount - the number of parameters
        paramTypes - the parameter type descriptors
        exceptionHandlerCount - the number of exception table entries
        monitorCount - the number of monitorenter/monitorexit instructions
        externalCallTargets - the called method references
        fieldAccessTargets - the accessed field references
        instantiatedTypes - the class names created with new
    • Method Detail

      • normalizeType

        public static String normalizeType​(String desc)
        Collapses a type descriptor into a coarse category: O for objects, P for primitives, V for void, with one A per array dimension prefixed.
        Parameters:
        desc - the type descriptor; null or empty is treated as void
        Returns:
        the category string
      • computeHash

        public byte[] computeHash()
        Description copied from interface: FeatureVector
        Digests every extracted feature into a hash usable for equality and lookup.
        Specified by:
        computeHash in interface FeatureVector
        Returns:
        the digest bytes
      • isValid

        public boolean isValid()
        Specified by:
        isValid in interface FeatureVector
        Returns:
        true if extraction produced features that can be matched against
      • similarity

        public double similarity​(Level0Features other)
        Scores similarity to another level-0 feature set as a weighted mix of exact matches and Jaccard overlaps.
        Parameters:
        other - the feature set to compare against
        Returns:
        a score in [0, 1], 0 if other is null
      • getReturnTypeCategory

        public String getReturnTypeCategory()
        Returns:
        the return type category
      • getParameterCount

        public int getParameterCount()
        Returns:
        the parameter count
      • getSortedParamCategories

        public List<String> getSortedParamCategories()
        Returns:
        an unmodifiable view of the normalized parameter categories, sorted
      • getExceptionHandlerCount

        public int getExceptionHandlerCount()
        Returns:
        the exception handler count
      • getMonitorCount

        public int getMonitorCount()
        Returns:
        the monitor count
      • getExternalCallTargets

        public Set<String> getExternalCallTargets()
        Returns:
        an unmodifiable view of the called method references
      • getFieldAccessTargets

        public Set<String> getFieldAccessTargets()
        Returns:
        an unmodifiable view of the accessed field references
      • getInstantiatedTypes

        public Set<String> getInstantiatedTypes()
        Returns:
        an unmodifiable view of the instantiated class names