8

Is there a tool out there for minifying java source code?

I am aware there is not much practical need for such a tool, but I am interested to reduce some students' code to 'bare bones' to show how their variable names are interpreted (sort-of -- it will heopfully re-enforce that their choice of variable names are disregarded) by the compiler. (The next step in this pedagogical process might be to show them the compiled code).

Thanks.

jedierikb
  • 12,752
  • 22
  • 95
  • 166
  • 1
    For Java _source_? I don't know of any. ProGuard deals with bytecode. – Louis Wasserman Nov 29 '12 at 21:54
  • 1
    I'm not so sure that would be such a good example of how the compiler interprets variable names. – Dan Nov 29 '12 at 21:57
  • A similar question was already discussed here: stackoverflow.com/questions/2537568/best-java-obfuscator Like @dystroy said, Progard is the most popular one. – tuga Nov 29 '12 at 22:06
  • related: http://stackoverflow.com/questions/12154553/how-to-obfuscate-code-without-compiling-the-project – jedierikb Nov 30 '12 at 15:17
  • this http://stackoverflow.com/questions/1967987 is also related. In particular, http://spoon.gforge.inria.fr/ seems to be a good base for this kind of source-to-source transformation. – ddevienne Aug 19 '14 at 12:52

1 Answers1

9

In the java world we mostly speak, due to the purpose, of obfuscation (even if in my opinion the impact on application file size can be useful, I used it a lot on Android applications a few years ago).

The best java obfuscator is probably Progard. Like all of them, it can reduce all (non exported) class and/or variable names to just a letter, which is part of the obfuscation as well as part of a minification.

You will have to decompile the bytecode afterwards if you want to show some java.

Community
  • 1
  • 1
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758