Java ME Wireless Toolkit Obfuscator Plugin
Zelix KlassMaster provides an obfuscator plugin to the Sun Java ME Wireless Toolkit to allow you to obfuscate your
Java ME MIDlets with a mimimum of effort. However, note that you can avoid the use of a plugin by obfuscating after preverification.
Please see the Java ME Obfuscation Tutorial for more detail.
This rest of this document is organized into the following sections.
Setting up the Zelix KlassMaster plugin involves editing the Wireless Toolkit ktools.properties file.
Location of the ktools.properties file
Operating System |
Location |
Linux |
<j2mewtk.dir>/wtklib/Linux/ktools.properties |
Solaris |
<j2mewtk.dir>/wtklib/SunOS/ktools.properties |
Windows |
<j2mewtk.dir>\wtklib\Windows\ktools.properties |
The ktools.properties file should be edited as follows
Relevant ktools.properties entries
Key |
Value |
obfuscator.runner.class.name |
com.zelix.ZKMWtkPlugin |
obfuscator.runner.classpath |
<path to ZKM.jar>ZKM.jar |
The <path to ZKM.jar> can be absolute or relative. If it is relative, it should be relative to <j2mewtk.dir> .
Note that, in the Windows environment, if the obfuscator.runner.classpath value contains path separators then they must be escaped.
For example, the path "c:\Projects\ZKM.jar " must be entered as "c:\\Projects\\ZKM.jar "
The obfuscator.script.name entry in the ktools.properties file is not used by the Zelix KlassMaster plugin.
If it is present in the file you can leave it unchanged or you can comment it out using a leading "#" character.
You should not have to add, delete or modify any other entries.
You run the plugin from the Java ME Wireless Toolkit KToolBar. The steps are
- Start the Java ME Wireless Toolkit KToolBar application
- Open your project
- Select the KToolBar "Project | Package | Create Obfuscated Package" menu option
The obfuscated JAR file and the updated JAD will be in your project directory.
The Zelix KlassMaster plugin sets its default directory to the project directory of the project you have opened within the KToolBar.
So the Zelix KlassMaster log file ZKM_log.txt and change log ChangeLog.txt will be written there.
Zelix KlassMaster will also look in the project directory for the default exclusion file defaultExclude.txt and the
default trim exclusion file defaultTrimExclude.txt .
By default, the plugin will use the following internal ZKM Script which aims at a balance between size and protection against decompilation.
trimExclude public *.* extends javax.microedition.midlet.MIDlet;
trim deleteSourceFileAttributes=true
deleteDeprecatedAttributes=true
deleteUnknownAttributes=false;
//Toolkit doesn't allow JAD to be updated so MIDlet package names must not be changed.
exclude public *.^* extends javax.microedition.midlet.MIDlet;
obfuscate changeLogFileOut="ChangeLog.txt"
obfuscateFlow=aggressive
encryptStringLiterals=none
collapsePackagesWithDefault=""
lineNumbers=delete;
|
You can provide your own ZKM Script by putting it in a file named script.txt in your project directory.
You could achieve further size reduction (at the expense of protection) by setting the ZKM Script obfuscate statement's "obfuscateFlow" parameter to "none"
to switch off flow obfuscation.
However, your script shouldn't specify
because these must be provided by the plugin. It would be a good idea to use the default script above as a model.
|