Contents Previous Next Index

Appendix   B

Support for ByteCode Obfuscators


The Wireless Toolkit contains a support framework for bytecode obfuscators. It also includes a plug-in for this framework for the ProGuard and Retroguard bytecode obfuscators. You can use a bytecode obfuscator other than ProGuard or RetroGuard, however, you must manually implement the plug-in for it. This appendix describes the implementation procedure.

Adding a ByteCode Obfuscator

To plug in a bytecode obfuscator of your choice into the Wireless Toolkit’s packaging process, you must follow these steps:

  1. Write your own Java class that implements the com.sun.kvem.environment.Obfuscator interface.
  2. The class file for this interface is located in the {j2mewtk.dir}\wtklib\kenv.zip file. The implementation class needs to implement the following two interface methods:

    where

    jarFileObfuscated is the file that holds the obfuscated JAR

    wtkBinDir is the directory holding the Wireless Toolkit binary files

    wtkLibDir is the directory holding the Wireless Toolkit JAR files

    jarFilename is the full path to the JAR file to be obfuscated

    projectDir is the full path to the main directory of your project

    classPath is the full path to the set of files that make up the API classpath for the project based on your API selections in the Project Settings dialog box, for example, the paths for the cldcapi10.jar and midpapi20.jar files.

    emptyApi is the full path to the version of the MIDP API containing stub methods (that is, method signatures without method bodies) in the {j2mewtk.dir}\wtklib directory

    The first method creates a script file that is used by most obfuscators as a method of input to determine which classes and methods are not to be obfuscated. The second method is called when the Wireless Toolkit attempts to execute the obfuscator.

  3. You must add the following properties to the ktools.properties file located in {j2mewtk.dir}\wtklib\Windows:

Example

For example, the Wireless Toolkit has an implementation that executes the ProGuard obfuscator. The class name is com.sun.kvem.ktools.RunPro and it is located in the ktools.zip file in the wtklib directory. The properties’ values are:

You can get the proguard.jar file by downloading the .zip file from
http://proguard.sourceforge.net/ and extracting the .jar file. The proguard.jar file must be placed in the Wireless Toolkit’s bin directory: {j2mewtk.dir}\bin.

 


Contents Previous Next Index Basic Customization Guide
Java™ 2 Platform, Micro Edition, Wireless Toolkit, Version 2.1