Any java instance for `/ usr / bin / strip`?

Is there any tool that can remove debugging information from Java.class files, just as /usr/bin/strip can from C / C ++ object files on Linux?

EDIT: I liked the answers of Thilo and Peter Mmm: Peter was short and brought to my ignorance of the fact that ships with JDK; The Thilo ProGuard offer is something that I will definitely check in any case for all these additional features that it seems to provide. Thanks to Tilo and Peter!

+4
source share
1 answer

ProGuard (which, for example, comes with an Android SDK to reduce code size), you can do all kinds of manipulations to compress JAR files

  • Calculate constant expressions.
  • Remove unnecessary field calls and method calls.
  • Delete unnecessary branches.
  • Remove unnecessary comparisons and test instances.
  • Remove unused code blocks.
  • Merge identical code blocks.
  • Reduce the selection of variables.
  • Delete write-only fields and unused method parameters.
  • Internal constant fields, method parameters, and return values.
  • Built-in methods, short or only called once.
  • Simplification of tail recursion calls.
  • Combine classes and interfaces.
  • Make methods private, static, and final when possible.
  • Make classes static and final whenever possible.
  • Replace interfaces with single implementations.
  • Perform over 200 optimizations in the form of bitmaps, such as replacing ... * 2 with ... <1.
  • It is not necessary to delete the registration code.

They do not mention deleting debugging information in this list, but I think they can do it as well.

Update: Yes, indeed:

By default, the compiled bytecode still contains a lot of debugging information: source file names, line numbers, field names, method names, argument names, variable names, etc. This information makes it easy to decompile bytecode and reverse entire programs. This is sometimes undesirable. Obfuscators such as ProGuard can remove debugging information and replace all names with meaningless sequences of characters, which greatly complicates the process of code conversion. It further compresses the code as a bonus. The program remains functionally equivalent, with the exception of class names, method names, and line numbers specified in the exception stack trace.

+3
source

Source: https://habr.com/ru/post/1343150/


All Articles