Frequently Asked Questions

Contents

  1. What is shrinking?
  2. What is obfuscation?
  3. Does ProGuard work with JDK1.4?
  4. Does ProGuard handle Class.forName calls?
  5. Does ProGuard handle resource files?
  6. Does ProGuard come with a GUI?
 

What is shrinking?

Java source code (.java files) is typically compiled to bytecode (.class files). Complete programs or program libraries are usually zipped up and distributed as Java archives (.jar files). Bytecode is more compact than Java source code, but it may still contain a lot of unused code, especially if it uses program libraries. Shrinking programs such as ProGuard can analyze bytecode and remove unused packages, classes, fields, and methods. The program remains functionally equivalent, including the information given in exception stack traces.

 

What is obfuscation?

By default, compiled bytecode still contains a lot of debugging information: source file names, line numbers, field names, method names, argument names, variable names, etc. This information makes it straightforward to decompile the bytecode and reverse-engineer entire programs. Sometimes, this is not desirable. Obfuscators such as ProGuard can remove the debugging information and replace all names by meaningless character sequences, making it much harder to reverse-engineer the code. It further compacts the code as a bonus. The program remains functionally equivalent, except for the class names, method names, and line numbers given in exception stack traces.

 

Does ProGuard work with JDK1.4?

Yes. Class files compiled with the javac compiler of JDK1.4 are targeted at JRE 1.2 by default. These class files have a slightly different structure than before. The new class files fall within the specifications, so they will run on most virtual machines, but they may trip some obfuscators. ProGuard handles both class file structures correctly.

 

Does ProGuard handle Class.forName calls?

Yes. As of version 1.1, ProGuard automatically handles Class.forName("SomeClass") and SomeClass.class constructs. The referenced classes are preserved in the shrinking phase, and the string arguments are properly replaced in the obfuscation phase.

With variable string arguments, it's generally not possible to determine their possible values (they might be read from a configuration file, for instance). However, ProGuard will note constructs like "(SomeClass)Class.forName(variable).newInstance()". These might be an indication that the class or interface SomeClass and/or its implementations may need to be preserved. The user can adapt his configuration accordingly.

 

Does ProGuard handle resource files?

Not specifically. For the moment, ProGuard ignores any resource files. You will have to add them manually, or include them in a separate jar.

 

Does ProGuard come with a GUI?

No. ProGuard is a command-line tool, designed to be easily integrated into any automatic build process. Configuration is done using a few compact and powerful options; just have a look at the examples in the User Manual. A graphical user interface to create configuration files is on the list of things to do, but it has a fairly low priority.


Copyright © 2002 Eric Lafortune.