2
2
* ProGuard -- shrinking, optimization, obfuscation, and preverification
5
* Copyright (c) 2002-2008 Eric Lafortune (eric@graphics.cornell.edu)
5
* Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu)
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
54
54
public void execute(ClassPool programClassPool,
55
55
ClassPool libraryClassPool) throws IOException
57
WarningPrinter warningPrinter = configuration.warn ?
58
new WarningPrinter(System.err) :
61
WarningPrinter notePrinter = configuration.note ?
62
new WarningPrinter(System.out) :
65
DuplicateClassPrinter duplicateClassPrinter = configuration.note ?
66
new DuplicateClassPrinter(notePrinter) :
69
57
// Check if we have at least some input classes.
70
58
if (configuration.programJars == null)
72
60
throw new IOException("The input is empty. You have to specify one or more '-injars' options");
63
// Perform some sanity checks on the class paths.
64
checkInputOutput(configuration.libraryJars,
65
configuration.programJars);
66
checkInputOutput(configuration.programJars,
67
configuration.programJars);
69
WarningPrinter warningPrinter = new WarningPrinter(System.err, configuration.warn);
70
WarningPrinter notePrinter = new WarningPrinter(System.out, configuration.note);
72
DuplicateClassPrinter duplicateClassPrinter = new DuplicateClassPrinter(notePrinter);
75
74
// Read the program class files.
76
75
// Prepare a data entry reader to filter all classes,
77
76
// which are then decoded to classes by a class reader,
113
112
// Print out a summary of the notes, if necessary.
114
if (notePrinter != null)
113
int noteCount = notePrinter.getWarningCount();
116
int noteCount = notePrinter.getWarningCount();
119
System.err.println("Note: there were " + noteCount +
120
" duplicate class definitions.");
116
System.err.println("Note: there were " + noteCount +
117
" duplicate class definitions.");
124
120
// Print out a summary of the warnings, if necessary.
125
if (warningPrinter != null)
127
int warningCount = warningPrinter.getWarningCount();
128
if (warningCount > 0)
130
System.err.println("Warning: there were " + warningCount +
131
" classes in incorrectly named files.");
132
System.err.println(" You should make sure all file names correspond to their class names.");
133
System.err.println(" The directory hierarchies must correspond to the package hierarchies.");
135
if (!configuration.ignoreWarnings)
121
int warningCount = warningPrinter.getWarningCount();
122
if (warningCount > 0)
124
System.err.println("Warning: there were " + warningCount +
125
" classes in incorrectly named files.");
126
System.err.println(" You should make sure all file names correspond to their class names.");
127
System.err.println(" The directory hierarchies must correspond to the package hierarchies.");
129
if (!configuration.ignoreWarnings)
131
System.err.println(" If you don't mind the mentioned classes not being written out,");
132
System.err.println(" you could try your luck using the '-ignorewarnings' option.");
133
throw new IOException("Please correct the above warnings first.");
140
* Performs some sanity checks on the class paths.
142
private void checkInputOutput(ClassPath inputClassPath,
143
ClassPath outputClassPath)
146
if (inputClassPath == null ||
147
outputClassPath == null)
152
for (int index1 = 0; index1 < inputClassPath.size(); index1++)
154
ClassPathEntry entry1 = inputClassPath.get(index1);
155
if (!entry1.isOutput())
157
for (int index2 = 0; index2 < outputClassPath.size(); index2++)
137
System.err.println(" If you don't mind the mentioned classes not being written out,");
138
System.err.println(" you could try your luck using the '-ignorewarnings' option.");
139
throw new IOException("Please correct the above warnings first.");
159
ClassPathEntry entry2 = outputClassPath.get(index2);
160
if (entry2.isOutput() &&
161
entry2.getName().equals(entry1.getName()))
163
throw new IOException("Input jars and output jars must be different ["+entry1.getName()+"]");