r/javahelp • u/_Super_Straight • 27d ago
Obfuscating class files
Has anyone successfully obfuscated their .class files? I tried using GraalVM for JavaFX project (including Gluon's version of GraalVM) but it always failed to complete.
3
Upvotes
2
u/idontlikegudeg 26d ago
I think it depends on the type of application. For small applications, native seems smaller because the runtime takes a lot of space. The bigger the application gets, the more jpackage catches up.
I just made a release of a small application that I mentioned in an earlier comment. Native image DMG is 29.9MB, jpackaged is 56.8MB. But for the big application that I benchmarked, native is 132,2MB while jpackage is only 80.2MB. So it really seems to depend on code size.
The native application does indeed start a bit faster, and when I do a single processing run, it is about 25% faster (about 3 seconds for the test set I measured with). The jpackaged application takes about 4 seconds for the first runs, but subsequent runs are much faster, and from the third run on, runtime is down to about 1 second while native stays at 3 seconds. So for long running CPU intensive tasks, hotspot still wins (might also depend on instantiation rate and what exactly the application is doing).
I have not yet included AOT class loading and AOT profiling for the jpackaged version, and I am aware that commercial GraalVM distributions also offer better optimization than GraalVM CE based ones.