Class ExportHprof.Remap

java.lang.Object
org.eclipse.mat.hprof.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 Details

    • 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 - matvch field names across classes
      undo - Just use existing remappings
  • Method Details

    • 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 - if there is a problem reading the mapping file
    • saveMapping

      public void saveMapping(File mapFile, boolean undo, String comments) throws IOException
      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 - the signature
      Returns:
      null if not renamed
    • renameFileName

      public String renameFileName(String classname, String filename)
      Rename a file name based on a class name.
      Parameters:
      classname - the class name in Memory Analyzer format
      filename - the Java source file name
      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 - the method signature in Memory Analyzer format
      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 - the class name in Memory Analyzer format
      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 - the class name in Memory Analyzer format
      Returns:
      the renamed class name, or the original name if no renaming is to be done for this class
    • renameClassOrMethodName

      public String renameClassOrMethodName(String classname)
      Renames a class, or a method pseudo-class.
      Parameters:
      classname - the class or class+method name
      Returns:
      the renamed class name, or the original name if no renaming is to be done for this class