damjan
damjan

Reputation: 1012

Optimizing Java bytecode?

I have a program that is about 300 times slower on a Java ME phone than on Java SE. Simple benchmarks show that manually inlining a method roughly doubles the phone's performance, and manually eliminating a common expression roughly doubles performance yet again. Clearly the Java ME implementation doesn't do any optimization.

Is there any compiler that takes Java source code and produces optimized Java bytecode (with method inlining, constant value propagation, common expression elimination, and other general optimizations)? Is there any other tools that optimize class files this way after compilation?

Upvotes: 3

Views: 573

Answers (1)

Joachim Sauer
Joachim Sauer

Reputation: 308031

Bytecode obfuscators often provide that kind of feature.

The reason for this is that obfuscators are often used in limted environments like Java ME. This is not primarily for making the code harder to de-compile, but to reduce the size of the compiled class files and possibly speed up their execution.

Try ProGuard, which is free software and supports some optimizations.

Upvotes: 4

Related Questions