Zelix KlassMaster - Documentation

Obfuscating Java ME™ MIDlets using Zelix KlassMaster™

Zelix KlassMaster™ can obfuscate Java ME MIDlets before or after preverification. However, it is usually easiest and most effective to obfuscate after preverification. There are two reasons for this
  1. If the preverification is done automatically by an IDE then the IDE usually requires a special obfuscation plugin that it can call between its compile and preverification steps. Unfortunately, obfuscation plugins can limit the obfuscation options available to you.
  2. If the preverification is done by a utility then that utility may not open classes from a JAR file. This can complicate your build process.

Obfuscating after preverification

If you obfuscate after preverification then Zelix KlassMaster™ will automatically update the preverification data structures in the bytecode. This means that you can easily add the obfuscation step to the end of your Java ME build prepocess without the need of a special IDE plugin.

Note that you must include your JAD file in your ZKM Script open statement along with your JAR file so that Zelix KlassMaster™ can update it. Also make sure that your classpath statement contains the CLDC bootstrap classes rather than the Standard Edition bootstrap classes. Zelix KlassMaster™ must use the CLDC versions of classes such as java.lang.Object and java.lang.Throwable.

Obfuscating before preverification

If you obfuscate before preverification then you may need a special plugin. There is a Zelix KlassMaster™ plugin for the Sun Wireless Toolkit but it does slightly limit the obfuscation options that you can specify. For example the Toolkit doesn't allow Zelix KlassMaster™ to update the JAD so MIDlet fully qualified names cannot be changed.

Suggested options

  • trim your classes after setting your trim exclusions using the ZKM Script trimExclude statement trimExclude *.* extends javax.microedition.midlet.MIDlet;
  • obfuscate your classes after setting your name exclusions using the ZKM Script exclude statement exclude *.* extends javax.microedition.midlet.MIDlet;
  • to reduce bytecode size you can use the following obfuscate statement parameters
    • collapsePackagesWithDefault=""
    • lineNumbers=delete
    • encryptStringLiterals=none
  • to improve bytecode protection without greatly increasing its size you can use the obfuscate statement's obfuscateFlow=light parameter.
 
Documentation Table of Contents