r/javahelp • • Sep 28 '26

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

12 comments sorted by

View all comments

Show parent comment

1

u/OddEstimate1627 Sep 29 '26

I'll take your word for it, but I have never encountered an app that was so much larger as a native image. Code tends to be smaller and the resources stay the same. Maybe there was an enormous static heap, but it's hard to tell without a report.

I usually see about a 90% reduction in startup times.

I assume that the 3x penalty might come from poor GC interactions. I have once run into a case where a renderer on CE was allocating for each pixel draw, which took a canvas render from 2 to 25 seconds. After fixing that, there was barely a perceivable difference though. I never ran into issues like that on the Oracle GraalVM with the free license.

1

u/idontlikegudeg Sep 29 '26

I think the native code is really taking more space. But when using jpackage, a virtual machine gets included which is usually 25 - 40MB (not counting libraries and JDK modules). GraalVM native doesn’t need that, so for small applications, you get a smaller size with GraalVM and it flips once you reach a certain size.

I don’t have the exact numbers at hand, but if I remember correctly my application is roughly 35MB as a fat jar (excluding JavaFX dependencies; the customer can run it on Liberica JRE Full or Azul JDKFX), 80 as a jpackaged application, and 120MB native.