SuperOptimize, boost your SuperWaba programs!

Logo di SuperOptimize
L’articolo che segue è in lingua inglese, è disponibile anche la traduzione in italiano.

SuperOptimize is a tool I wrote to automatically shrink, optimize and obfuscate SuperWaba programs.

SuperOptimize is not maintained anymore, if you think you still need it, please contact me.

What is SuperOptimize?

SuperOptimize is a package to shrink, obfuscate and optimize your Java code for SuperWaba. The resulting files will be smaller, obfuscated, and heavily optimized.
Unlike the standard tools that come with the SuperWaba SDK, SuperOptimize uses the most advanced OpenSource tools available for the best results: the Soot framework for optimizations and ProGuard for shrinking and obfuscating.

Why optimize?

Soot is the key component for the optimization of your programs. It uses four intermediate code representations for analyzing and transforming Java bytecode. The result is usually slightly bigger, but more efficient code.

Why shrink?

Shinking means removing all the classes and methods that are never used in your programs. This might sound strange, but it happens more than often. Of course shrinking means producing smaller files that take less time to load and consume less memory.

Why obfuscate?

In the SuperWaba VM, like almost every Java VM, packages, methods, attributes and classes are looked up by name. That means, searching strings at run time. This is not particularly good for performance, especially with long strings beginning with the same characters (and that happens quite often, too).
Obfuscating is the process in which classes, methods, attributes and packages are renamed into very short strings like “A” or “bc” that take less to be searched by the VM. This also produces smaller binaries that consume less memory and take less time to load.
Obfuscating your .class files makes it also more difficult for others to understand your program by disassembling it. It’s far from making reverse-engineering difficult though, so don’t rely on it very much from a security point of view.

Get it!

You may download SuperOptimize and use it for free, since it is released under the GPL. SuperOptimize uses the SuperWaba GPL library, so it can’t be used for commercial purposes. If you need a non-GPL’d version, please email me.

How to use it

First of all, JDK 1.2.2 is needed. That particular version produces the best code for SuperWaba, and it’s the only one tested with SuperOptimize. So download it from Sun’s site. Install it in a location you like.
Apache Ant is also needed. If you use the Eclipse platform (highly recommended), you’ll already have it installed. In that case, create a new project and import all the files in the distribution package. If you aren’t using Eclipse you can just launch SuperOptimize running Ant with no arguments from the command line.
Before running Ant though, you’ll have to open the build.xml file, and adjust the lines:
<!– Path for the JDK 1.2 –>
<property name=”java12home” value=”/opt/jdk1.2.2″/>
<!– Name of the main class –>
<property name=”mainClass” value=”superwaba.samples.app.swcalc.SWCalc”/>
<!– Name of the program –>
<property name=”programName” value=”SWCalc”/>
with the appropriate values, and copy your source files in the src/ folder.
Then just run Ant (either from the command line or from the Eclipse menu) and SuperOptimize will compile, optimize, shrink and obfuscate the code, producing the executable file with its pdb.

Results

I used SuperOptimize for only one project that really needed optimization. Results were quite surprising:

  • file size went from over 500 kb to less than 150 kb and
  • execution time of the main task was reduced about 40%.

I think these are extreme results, but I’m sure it could help you anyway, whatever project you have. I’ll post here your results if you send me an email.

Problems? Comments? Suggestions?

If you have any question, please email me at the address: silvio at moioli dot net

Comments are closed.