Class ExportHprof.Remap

  • Enclosing class:
    ExportHprof

    public static class ExportHprof.Remap
    extends Object
    Remaps class names. Separate class to isolate the generation of names from the actual contents of the snapshot.
    • Constructor Detail

      • Remap

        public Remap​(Pattern skipPattern,
                     Pattern avoidPattern,
                     boolean matchFields,
                     boolean undo)
        Create a remapper
        Parameters:
        skipPattern - Remap names unless they match this
        avoidPattern - Avoid remapping to names which match this
        matchFields - TODO
        undo - Just use existing remappings
    • Method Detail

      • loadMapping

        public void loadMapping​(File mapFile,
                                boolean undo)
                         throws IOException
        Load the existing mapping table from a mapping properties file. Properties file format: original.package.Classname=new.package.Classname
        Parameters:
        mapFile - the Java format properties file
        undo - whether to reverse the mappings contained in the file
        Throws:
        IOException
      • isRemapped

        public boolean isRemapped​(String cn)
        Is the class name one which should have a new name invented?
        Parameters:
        cn -
        Returns:
        true if the class name is to be changed
      • mapClass

        public String mapClass​(String cn)
        Return the renamed version of a class
        Parameters:
        cn -
        Returns:
        null if not renamed
      • mapField

        public String mapField​(String cn)
        Return the renamed version of a simple field/method
        Parameters:
        cn -
        Returns:
        null if not renamed
      • mapSignature

        public String mapSignature​(String sig)
        Return the renamed version of a method/type signature
        Parameters:
        sig -
        Returns:
        null if not renamed
      • renameFileName

        public String renameFileName​(String classname,
                                     String filename)
        Rename a file name based on a class name.
        Parameters:
        classname -
        filename -
        Returns:
        the renamed file name
      • renameSignature

        public String renameSignature​(String signature)
        Rename a method signature. Extract the class names from the Lpack1.class1;II)VLpack2.class2;
        Parameters:
        signature -
        Returns:
        renamed signature
      • renameMethodName

        public String renameMethodName​(String className,
                                       String method,
                                       boolean upper)
        Generate a new method name. Remember it as package.class^method - ? Some unusual Javac generated methods: HistogramQuery$Grouping.values() HistogramQuery.$SWITCH_TABLE$org$eclipse$mat$inspections$HistogramQuery$Grouping()
        Parameters:
        className -
        method - method name or field name
        upper - static field in upper case, else all lower case.
        Returns:
        the renamed method or field name
      • renameClassName

        public String renameClassName​(String classname)
        Renames a class. Break into component parts, reusing existing mapping for package if already used. Removes array suffixes and uses base class name. Translates inner classes with '$' piece by piece, reusing existing mapping of outer class.
        Parameters:
        classname -
        Returns:
        the renamed class name, or the original name if no renaming is to be done for this class