This article applies to the BlackBerry® Java Development Environment
Unlike traditional compilers, the compiler for the BlackBerry platform is highly optimized for a constrained mobile environment where the goal is to minimize the size of the application. The resulting COD file provides a significant amount of obfuscation-like services similar to other true obfuscation packages in an effort to reduce the size of the COD file. For example, the following information is removed from a COD file:
All debug information
Local variable names
Source Line Numbers
Private Method and Members names
As such, Research in Motion® (RIM) does not believe it is necessary for companies to provide obfuscation for their applications on top of the existing obfuscation provided by default for all applications compiled for the BlackBerry platform. In fact, RIM does not perform any additional obfuscation of its own products today.
Support for obfuscation via third-party tools is not integrated into the JDE. As such, a command line procedure is required to obfuscate COD files for use on BlackBerry wireless devices. This article provides the steps and techniques required to obfuscate a COD file and have it execute properly on the BlackBerry device.
Create an application in the JDE. You should place the project file in a separate directory for ease of use during this process.
Create a temporary directory.
Copy the associated JAR file created by the BlackBerry JDE to the temporary directory.
Extract the contents of the JAR file into the temporary directory using the following command: jar xvf SampleApplication.jar
Delete the COD file (that was extracted as part of the JAR file) and the JAR file. You will replace these files in the following steps.
Obfuscate the class files that are contained in the temporary directory.
Run the pre-verify tool on the contents of the temporary directory using the following command: preverify.exe -verbose -d . -classpath..\lib\net_rim_api.jar;
Run rapc on the obfuscated (and pre-verified) class files to create a COD file. Use the following command: