~ubuntu-branches/ubuntu/wily/proguard/wily

« back to all changes in this revision

Viewing changes to src/proguard/retrace/ReTrace.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2014-04-10 13:58:11 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20140410135811-ddwzt2avu94rnolt
Tags: 4.11-1
* Team upload.
* New upstream release
* Removed the non-free documentation from the package (Closes: #719706)
* Removed the pre-built jars from the upstream tarball
* debian/control:
  - The package is now co-maintained with the Java Team
  - Standards-Version updated to 3.9.5 (no changes)
  - Added the Vcs-* fields
  - Added the Homepage field
* Switch to debhelper level 9
* Use XZ compression for the upstream tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * ProGuard -- shrinking, optimization, obfuscation, and preverification
3
3
 *             of Java bytecode.
4
4
 *
5
 
 * Copyright (c) 2002-2012 Eric Lafortune (eric@graphics.cornell.edu)
 
5
 * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu)
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify it
8
8
 * under the terms of the GNU General Public License as published by the Free
41
41
    private static final String VERBOSE_OPTION = "-verbose";
42
42
 
43
43
 
44
 
    public static final String STACK_TRACE_EXPRESSION = "(?:.*?\\bat\\s+%c.%m\\s*\\(.*?(?::%l)?\\)\\s*)|(?:(?:.*?[:\"]\\s+)?%c(?::.*)?)";
 
44
    public static final String STACK_TRACE_EXPRESSION = "(?:.*?\\bat\\s+%c\\.%m\\s*\\(.*?(?::%l)?\\)\\s*)|(?:(?:.*?[:\"]\\s+)?%c(?::.*)?)";
45
45
 
46
46
    private static final String REGEX_CLASS       = "\\b(?:[A-Za-z0-9_$]+\\.)*[A-Za-z0-9_$]+\\b";
47
47
    private static final String REGEX_CLASS_SLASH = "\\b(?:[A-Za-z0-9_$]+/)*[A-Za-z0-9_$]+\\b";
112
112
        MappingReader mappingReader = new MappingReader(mappingFile);
113
113
        mappingReader.pump(this);
114
114
 
115
 
 
 
115
        // Construct the regular expression.
116
116
        StringBuffer expressionBuffer    = new StringBuffer(regularExpression.length() + 32);
117
117
        char[]       expressionTypes     = new char[32];
118
118
        int          expressionTypeCount = 0;
173
173
 
174
174
        Pattern pattern = Pattern.compile(expressionBuffer.toString());
175
175
 
176
 
        // Read the stack trace file.
 
176
        // Open the stack trace file.
177
177
        LineNumberReader reader =
178
178
            new LineNumberReader(stackTraceFile == null ?
179
179
                (Reader)new InputStreamReader(System.in) :
180
180
                (Reader)new BufferedReader(new FileReader(stackTraceFile)));
181
181
 
182
 
 
 
182
        // Read and process the lines of the stack trace.
183
183
        try
184
184
        {
185
 
            StringBuffer outLine = new StringBuffer(256);
186
 
            List         extraOutLines  = new ArrayList();
 
185
            StringBuffer outLine       = new StringBuffer(256);
 
186
            List         extraOutLines = new ArrayList();
187
187
 
188
188
            String className = null;
189
189
 
190
 
            // Read the line in the stack trace.
 
190
            // Read all lines from the stack trace.
191
191
            while (true)
192
192
            {
 
193
                // Read a line.
193
194
                String line = reader.readLine();
194
195
                if (line == null)
195
196
                {
196
197
                    break;
197
198
                }
198
199
 
 
200
                // Try to match it against the regular expression.
199
201
                Matcher matcher = pattern.matcher(line);
200
202
 
201
203
                if (matcher.matches())
202
204
                {
 
205
                    // The line matched the regular expression.
203
206
                    int    lineNumber = 0;
204
207
                    String type       = null;
205
208
                    String arguments  = null;
206
209
 
207
 
                    // Figure out a class name, line number, type, and
208
 
                    // arguments beforehand.
 
210
                    // Extract a class name, a line number, a type, and
 
211
                    // arguments.
209
212
                    for (int expressionTypeIndex = 0; expressionTypeIndex < expressionTypeCount; expressionTypeIndex++)
210
213
                    {
211
214
                        int startIndex = matcher.start(expressionTypeIndex + 1);
239
242
                        }
240
243
                    }
241
244
 
242
 
                    // Actually construct the output line.
 
245
                    // Deconstruct the input line and reconstruct the output
 
246
                    // line. Also collect any additional output lines for this
 
247
                    // line.
243
248
                    int lineIndex = 0;
244
249
 
245
250
                    outLine.setLength(0);
253
258
                            int    endIndex = matcher.end(expressionTypeIndex + 1);
254
259
                            String match    = matcher.group(expressionTypeIndex + 1);
255
260
 
256
 
                            // Copy a literal piece of input line.
 
261
                            // Copy a literal piece of the input line.
257
262
                            outLine.append(line.substring(lineIndex, startIndex));
258
263
 
 
264
                            // Copy a matched and translated piece of the input line.
259
265
                            char expressionType = expressionTypes[expressionTypeIndex];
260
266
                            switch (expressionType)
261
267
                            {
309
315
                        }
310
316
                    }
311
317
 
312
 
                    // Copy the last literal piece of input line.
 
318
                    // Copy the last literal piece of the input line.
313
319
                    outLine.append(line.substring(lineIndex));
314
320
 
315
 
                    // Print out the main line.
 
321
                    // Print out the processed line.
316
322
                    System.out.println(outLine);
317
323
 
318
324
                    // Print out any additional lines.
323
329
                }
324
330
                else
325
331
                {
 
332
                    // The line didn't match the regular expression.
326
333
                    // Print out the original line.
327
334
                    System.out.println(line);
328
335
                }