retrace

16:51:10.898 INFO  jd.cli.Main - Decompiling retrace.jar
package proguard.retrace;

class ReTrace$MethodInfo
{
  private int firstLineNumber;
  private int lastLineNumber;
  private String type;
  private String arguments;
  private String originalName;
  
  ReTrace$MethodInfo(int paramInt1, int paramInt2, String paramString1, String paramString2, String paramString3, ReTrace.1 param1)
  {
    this(paramInt1, paramInt2, paramString1, paramString2, paramString3);
  }
  
  private ReTrace$MethodInfo(int paramInt1, int paramInt2, String paramString1, String paramString2, String paramString3)
  {
    firstLineNumber = paramInt1;
    lastLineNumber = paramInt2;
    type = paramString1;
    arguments = paramString2;
    originalName = paramString3;
  }
  
  private boolean matches(int paramInt, String paramString1, String paramString2)
  {
    return ((paramInt == 0) || ((firstLineNumber <= paramInt) && (paramInt <= lastLineNumber)) || (lastLineNumber == 0)) && ((paramString1 == null) || (paramString1.equals(type))) && ((paramString2 == null) || (paramString2.equals(arguments)));
  }
}

/* Location:
 * Qualified Name:     proguard.retrace.ReTrace.MethodInfo
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package proguard.retrace;

class ReTrace$1 {}

/* Location:
 * Qualified Name:     proguard.retrace.ReTrace.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package proguard.retrace;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import proguard.classfile.util.ClassUtil;
import proguard.obfuscate.MappingProcessor;
import proguard.obfuscate.MappingReader;

public class ReTrace
  implements MappingProcessor
{
  private static final String REGEX_OPTION = "-regex";
  private static final String VERBOSE_OPTION = "-verbose";
  public static final String STACK_TRACE_EXPRESSION = "(?:\\s*%c:.*)|(?:\\s*at\\s+%c.%m\\s*\\(.*?(?::%l)?\\)\\s*)";
  private static final String REGEX_CLASS = "\\b(?:[A-Za-z0-9_$]+\\.)*[A-Za-z0-9_$]+\\b";
  private static final String REGEX_CLASS_SLASH = "\\b(?:[A-Za-z0-9_$]+/)*[A-Za-z0-9_$]+\\b";
  private static final String REGEX_LINE_NUMBER = "\\b[0-9]+\\b";
  private static final String REGEX_TYPE = "\\b(?:[A-Za-z0-9_$]+\\.)*[A-Za-z0-9_$]+\\b(?:\\[\\])*";
  private static final String REGEX_MEMBER = "<?\\b[A-Za-z0-9_$]+\\b>?";
  private static final String REGEX_ARGUMENTS = "(?:\\b(?:[A-Za-z0-9_$]+\\.)*[A-Za-z0-9_$]+\\b(?:\\[\\])*(?:\\s*,\\s*\\b(?:[A-Za-z0-9_$]+\\.)*[A-Za-z0-9_$]+\\b(?:\\[\\])*)*)?";
  private final String regularExpression;
  private final boolean verbose;
  private final File mappingFile;
  private final File stackTraceFile;
  private Map classMap = new HashMap();
  private Map classFieldMap = new HashMap();
  private Map classMethodMap = new HashMap();
  
  public ReTrace(String paramString, boolean paramBoolean, File paramFile)
  {
    this(paramString, paramBoolean, paramFile, null);
  }
  
  public ReTrace(String paramString, boolean paramBoolean, File paramFile1, File paramFile2)
  {
    regularExpression = paramString;
    verbose = paramBoolean;
    mappingFile = paramFile1;
    stackTraceFile = paramFile2;
  }
  
  public void execute()
    throws IOException
  {
    MappingReader localMappingReader = new MappingReader(mappingFile);
    localMappingReader.pump(this);
    
    StringBuffer localStringBuffer1 = new StringBuffer(regularExpression.length() + 32);
    char[] arrayOfChar = new char[32];
    int i = 0;
    int j = 0;
    for (;;)
    {
      int k = regularExpression.indexOf('%', j);
      if ((k < 0) || (k == regularExpression.length() - 1) || (i == arrayOfChar.length)) {
        break;
      }
      localStringBuffer1.append(regularExpression.substring(j, k));
      localStringBuffer1.append('(');
      
      int m = regularExpression.charAt(k + 1);
      switch (m)
      {
      case 99: 
        localStringBuffer1.append("\\b(?:[A-Za-z0-9_$]+\\.)*[A-Za-z0-9_$]+\\b");
        break;
      case 67: 
        localStringBuffer1.append("\\b(?:[A-Za-z0-9_$]+/)*[A-Za-z0-9_$]+\\b");
        break;
      case 108: 
        localStringBuffer1.append("\\b[0-9]+\\b");
        break;
      case 116: 
        localStringBuffer1.append("\\b(?:[A-Za-z0-9_$]+\\.)*[A-Za-z0-9_$]+\\b(?:\\[\\])*");
        break;
      case 102: 
        localStringBuffer1.append("<?\\b[A-Za-z0-9_$]+\\b>?");
        break;
      case 109: 
        localStringBuffer1.append("<?\\b[A-Za-z0-9_$]+\\b>?");
        break;
      case 97: 
        localStringBuffer1.append("(?:\\b(?:[A-Za-z0-9_$]+\\.)*[A-Za-z0-9_$]+\\b(?:\\[\\])*(?:\\s*,\\s*\\b(?:[A-Za-z0-9_$]+\\.)*[A-Za-z0-9_$]+\\b(?:\\[\\])*)*)?");
      }
      localStringBuffer1.append(')');
      
      arrayOfChar[(i++)] = m;
      
      j = k + 2;
    }
    localStringBuffer1.append(regularExpression.substring(j));
    
    Pattern localPattern = Pattern.compile(localStringBuffer1.toString());
    
    LineNumberReader localLineNumberReader = new LineNumberReader(stackTraceFile == null ? new InputStreamReader(System.in) : new BufferedReader(new FileReader(stackTraceFile)));
    try
    {
      StringBuffer localStringBuffer2 = new StringBuffer(256);
      ArrayList localArrayList = new ArrayList();
      
      String str1 = null;
      for (;;)
      {
        String str2 = localLineNumberReader.readLine();
        if (str2 == null) {
          break;
        }
        Matcher localMatcher = localPattern.matcher(str2);
        if (localMatcher.matches())
        {
          int n = 0;
          String str3 = null;
          String str4 = null;
          int i4;
          for (int i1 = 0; i1 < i; i1++)
          {
            i2 = localMatcher.start(i1 + 1);
            if (i2 >= 0)
            {
              String str5 = localMatcher.group(i1 + 1);
              
              i4 = arrayOfChar[i1];
              switch (i4)
              {
              case 99: 
                str1 = originalClassName(str5);
                break;
              case 67: 
                str1 = originalClassName(ClassUtil.externalClassName(str5));
                break;
              case 108: 
                n = Integer.parseInt(str5);
                break;
              case 116: 
                str3 = originalType(str5);
                break;
              case 97: 
                str4 = originalArguments(str5);
              }
            }
          }
          i1 = 0;
          
          localStringBuffer2.setLength(0);
          localArrayList.clear();
          for (int i2 = 0; i2 < i; i2++)
          {
            int i3 = localMatcher.start(i2 + 1);
            if (i3 >= 0)
            {
              i4 = localMatcher.end(i2 + 1);
              String str6 = localMatcher.group(i2 + 1);
              
              localStringBuffer2.append(str2.substring(i1, i3));
              
              int i5 = arrayOfChar[i2];
              switch (i5)
              {
              case 99: 
                str1 = originalClassName(str6);
                localStringBuffer2.append(str1);
                break;
              case 67: 
                str1 = originalClassName(ClassUtil.externalClassName(str6));
                localStringBuffer2.append(ClassUtil.internalClassName(str1));
                break;
              case 108: 
                n = Integer.parseInt(str6);
                localStringBuffer2.append(str6);
                break;
              case 116: 
                str3 = originalType(str6);
                localStringBuffer2.append(str3);
                break;
              case 102: 
                originalFieldName(str1, str6, str3, localStringBuffer2, localArrayList);
                
                break;
              case 109: 
                originalMethodName(str1, str6, n, str3, str4, localStringBuffer2, localArrayList);
                
                break;
              case 97: 
                str4 = originalArguments(str6);
                localStringBuffer2.append(str4);
              }
              i1 = i4;
            }
          }
          localStringBuffer2.append(str2.substring(i1));
          
          System.out.println(localStringBuffer2);
          for (i2 = 0; i2 < localArrayList.size(); i2++) {
            System.out.println(localArrayList.get(i2));
          }
        }
        else
        {
          System.out.println(str2);
        }
      }
    }
    catch (IOException localIOException1)
    {
      throw new IOException("Can't read stack trace (" + localIOException1.getMessage() + ")");
    }
    finally
    {
      if (stackTraceFile != null) {
        try
        {
          localLineNumberReader.close();
        }
        catch (IOException localIOException2) {}
      }
    }
  }
  
  private void originalFieldName(String paramString1, String paramString2, String paramString3, StringBuffer paramStringBuffer, List paramList)
  {
    int i = -1;
    
    Map localMap = (Map)classFieldMap.get(paramString1);
    if (localMap != null)
    {
      Set localSet = (Set)localMap.get(paramString2);
      if (localSet != null)
      {
        Iterator localIterator = localSet.iterator();
        while (localIterator.hasNext())
        {
          FieldInfo localFieldInfo = (FieldInfo)localIterator.next();
          if (localFieldInfo.matches(paramString3)) {
            if (i < 0)
            {
              i = paramStringBuffer.length();
              if (verbose) {
                paramStringBuffer.append(type).append(' ');
              }
              paramStringBuffer.append(originalName);
            }
            else
            {
              StringBuffer localStringBuffer = new StringBuffer();
              for (int j = 0; j < i; j++) {
                localStringBuffer.append(' ');
              }
              if (verbose) {
                localStringBuffer.append(type).append(' ');
              }
              localStringBuffer.append(originalName);
              
              paramList.add(localStringBuffer);
            }
          }
        }
      }
    }
    if (i < 0) {
      paramStringBuffer.append(paramString2);
    }
  }
  
  private void originalMethodName(String paramString1, String paramString2, int paramInt, String paramString3, String paramString4, StringBuffer paramStringBuffer, List paramList)
  {
    int i = -1;
    
    Map localMap = (Map)classMethodMap.get(paramString1);
    if (localMap != null)
    {
      Set localSet = (Set)localMap.get(paramString2);
      if (localSet != null)
      {
        Iterator localIterator = localSet.iterator();
        while (localIterator.hasNext())
        {
          MethodInfo localMethodInfo = (MethodInfo)localIterator.next();
          if (localMethodInfo.matches(paramInt, paramString3, paramString4)) {
            if (i < 0)
            {
              i = paramStringBuffer.length();
              if (verbose) {
                paramStringBuffer.append(type).append(' ');
              }
              paramStringBuffer.append(originalName);
              if (verbose) {
                paramStringBuffer.append('(').append(arguments).append(')');
              }
            }
            else
            {
              StringBuffer localStringBuffer = new StringBuffer();
              for (int j = 0; j < i; j++) {
                localStringBuffer.append(' ');
              }
              if (verbose) {
                localStringBuffer.append(type).append(' ');
              }
              localStringBuffer.append(originalName);
              if (verbose) {
                localStringBuffer.append('(').append(arguments).append(')');
              }
              paramList.add(localStringBuffer);
            }
          }
        }
      }
    }
    if (i < 0) {
      paramStringBuffer.append(paramString2);
    }
  }
  
  private String originalArguments(String paramString)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    
    int i = 0;
    for (;;)
    {
      int j = paramString.indexOf(',', i);
      if (j < 0) {
        break;
      }
      localStringBuffer.append(originalType(paramString.substring(i, j).trim())).append(',');
      
      i = j + 1;
    }
    localStringBuffer.append(originalType(paramString.substring(i).trim()));
    
    return localStringBuffer.toString();
  }
  
  private String originalType(String paramString)
  {
    int i = paramString.indexOf('[');
    
    return i >= 0 ? originalClassName(paramString.substring(0, i)) + paramString.substring(i) : originalClassName(paramString);
  }
  
  private String originalClassName(String paramString)
  {
    String str = (String)classMap.get(paramString);
    
    return str != null ? str : paramString;
  }
  
  public boolean processClassMapping(String paramString1, String paramString2)
  {
    classMap.put(paramString2, paramString1);
    
    return true;
  }
  
  public void processFieldMapping(String paramString1, String paramString2, String paramString3, String paramString4)
  {
    Object localObject1 = (Map)classFieldMap.get(paramString1);
    if (localObject1 == null)
    {
      localObject1 = new HashMap();
      classFieldMap.put(paramString1, localObject1);
    }
    Object localObject2 = (Set)((Map)localObject1).get(paramString4);
    if (localObject2 == null)
    {
      localObject2 = new LinkedHashSet();
      ((Map)localObject1).put(paramString4, localObject2);
    }
    ((Set)localObject2).add(new FieldInfo(paramString2, paramString3, null));
  }
  
  public void processMethodMapping(String paramString1, int paramInt1, int paramInt2, String paramString2, String paramString3, String paramString4, String paramString5)
  {
    Object localObject1 = (Map)classMethodMap.get(paramString1);
    if (localObject1 == null)
    {
      localObject1 = new HashMap();
      classMethodMap.put(paramString1, localObject1);
    }
    Object localObject2 = (Set)((Map)localObject1).get(paramString5);
    if (localObject2 == null)
    {
      localObject2 = new LinkedHashSet();
      ((Map)localObject1).put(paramString5, localObject2);
    }
    ((Set)localObject2).add(new MethodInfo(paramInt1, paramInt2, paramString2, paramString4, paramString3, null));
  }
  
  private static class FieldInfo
  {
    private String type;
    private String originalName;
    
    FieldInfo(String paramString1, String paramString2, ReTrace.1 param1)
    {
      this(paramString1, paramString2);
    }
    
    private FieldInfo(String paramString1, String paramString2)
    {
      type = paramString1;
      originalName = paramString2;
    }
    
    private boolean matches(String paramString)
    {
      return (paramString == null) || (paramString.equals(type));
    }
  }
  
  private static class MethodInfo
  {
    private int firstLineNumber;
    private int lastLineNumber;
    private String type;
    private String arguments;
    private String originalName;
    
    MethodInfo(int paramInt1, int paramInt2, String paramString1, String paramString2, String paramString3, ReTrace.1 param1)
    {
      this(paramInt1, paramInt2, paramString1, paramString2, paramString3);
    }
    
    private MethodInfo(int paramInt1, int paramInt2, String paramString1, String paramString2, String paramString3)
    {
      firstLineNumber = paramInt1;
      lastLineNumber = paramInt2;
      type = paramString1;
      arguments = paramString2;
      originalName = paramString3;
    }
    
    private boolean matches(int paramInt, String paramString1, String paramString2)
    {
      return ((paramInt == 0) || ((firstLineNumber <= paramInt) && (paramInt <= lastLineNumber)) || (lastLineNumber == 0)) && ((paramString1 == null) || (paramString1.equals(type))) && ((paramString2 == null) || (paramString2.equals(arguments)));
    }
  }
  
  public static void main(String[] paramArrayOfString)
  {
    if (paramArrayOfString.length < 1)
    {
      System.err.println("Usage: java proguard.ReTrace [-verbose] <mapping_file> [<stacktrace_file>]");
      System.exit(-1);
    }
    String str = "(?:\\s*%c:.*)|(?:\\s*at\\s+%c.%m\\s*\\(.*?(?::%l)?\\)\\s*)";
    boolean bool = false;
    
    int i = 0;
    while (i < paramArrayOfString.length)
    {
      localObject = paramArrayOfString[i];
      if (((String)localObject).equals("-regex"))
      {
        str = paramArrayOfString[(++i)];
      }
      else
      {
        if (!((String)localObject).equals("-verbose")) {
          break;
        }
        bool = true;
      }
      i++;
    }
    if (i >= paramArrayOfString.length)
    {
      System.err.println("Usage: java proguard.ReTrace [-regex <regex>] [-verbose] <mapping_file> [<stacktrace_file>]");
      System.exit(-1);
    }
    Object localObject = new File(paramArrayOfString[(i++)]);
    File localFile = i < paramArrayOfString.length ? new File(paramArrayOfString[i]) : null;
    
    ReTrace localReTrace = new ReTrace(str, bool, (File)localObject, localFile);
    try
    {
      localReTrace.execute();
    }
    catch (IOException localIOException)
    {
      if (bool) {
        localIOException.printStackTrace();
      } else {
        System.err.println("Error: " + localIOException.getMessage());
      }
      System.exit(1);
    }
    System.exit(0);
  }
}

/* Location:
 * Qualified Name:     proguard.retrace.ReTrace
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package proguard.retrace;

class ReTrace$FieldInfo
{
  private String type;
  private String originalName;
  
  ReTrace$FieldInfo(String paramString1, String paramString2, ReTrace.1 param1)
  {
    this(paramString1, paramString2);
  }
  
  private ReTrace$FieldInfo(String paramString1, String paramString2)
  {
    type = paramString1;
    originalName = paramString2;
  }
  
  private boolean matches(String paramString)
  {
    return (paramString == null) || (paramString.equals(type));
  }
}

/* Location:
 * Qualified Name:     proguard.retrace.ReTrace.FieldInfo
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd