Boost your SuperWaba programs!
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 performant 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!
Here! (5 Mb download)
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.
That should be enough. Just run Ant (either from the command line or from the Eclipse menu) and SuperOptimize will compile, optimize, shrink and
obfuscate the code, and it will finally produce the executable file with its pdb. Ready to sync?
Results
I've only used SuperOptimize for my own project (it was actually created for that, since it really needed optimization). Results are quite
surprising:
- The file size went from over 500 kb to less than 150 kb
- The 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?
I tested SuperOptimize on the Eclipse platform on Linux only, because this is an early release. If you have any question, please email me at
the address:
silvio at moioli dot net
If you speak Italian, feel free to browse my site at www.moioli.net
License
SuperOptimize is released under the
GPL, and since it uses the SuperWaba GPL library it
can't be used for commercial purposes. If you need a non-GPL'd version, please email me.
Getting the Sources