Java jar 符号信息:相当于 tdstrip 的是什么?

发布于 2024-08-21 19:53:40 字数 237 浏览 9 评论 0原文

我有一个 1MB 的 .jar 文件。如果没有调试信息,它应该约为 100KB。现在,我如何删除调试信息?

来自 borland 世界的老朋友可能还记得一个名为 tdstrip 的工具,它可以从 .exe 中删除符号信息。

Java 世界中的等价物是什么?我正在尝试进行移动开发,1MB 的文件太大了。

我知道我可以在没有调试信息的情况下重新编译和重建 .jar 文件,但是如果您没有源代码等,您将如何去做呢?

I have a .jar file which is 1MB. Without debug info, it should be about 100KB. Now, how do I strip the debug info?

Oldtimers from the borland world might remember of a tool called tdstrip which would remove the symbol info from an .exe.

What is the equivalent in the Java world? I'm trying to do mobile development where a 1MB file is way too big.

I know that I could recompile and rebuild the .jar file without the debug info, but if you don't have sources, etc, how do you go about doing it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

难理解 2024-08-28 19:53:40

使用%JAVA_HOME%/bin/pack200 -r -G jartostrip.jar

Usage:  pack200 [-opt... | --option=value]... x.pack[.gz] y.jar

Packing Options
  -g, --no-gzip                   output a plain *.pack file with no zipping
  --gzip                          (default) post-process the pack output with gzip
  -G, --strip-debug               remove debugging attributes while packing
  -O, --no-keep-file-order        do not transmit file ordering information
  --keep-file-order               (default) preserve input file ordering
  -S{N}, --segment-limit={N}      output segment limit (default N=1Mb)
  -E{N}, --effort={N}             packing effort (default N=5)
  -H{h}, --deflate-hint={h}       transmit deflate hint: true, false, or keep (default)
  -m{V}, --modification-time={V}  transmit modtimes: latest or keep (default)
  -P{F}, --pass-file={F}          transmit the given input element(s) uncompressed
  -U{a}, --unknown-attribute={a}  unknown attribute action: error, strip, or pass (default)
  -C{N}={L}, --class-attribute={N}={L}  (user-defined attribute)
  -F{N}={L}, --field-attribute={N}={L}  (user-defined attribute)
  -M{N}={L}, --method-attribute={N}={L} (user-defined attribute)
  -D{N}={L}, --code-attribute={N}={L}   (user-defined attribute)
  -f{F}, --config-file={F}        read file F for Pack200.Packer properties
  -v, --verbose                   increase program verbosity
  -q, --quiet                     set verbosity to lowest level
  -l{F}, --log-file={F}           output to the given log file, or '-' for System.out
  -?, -h, --help                  print this message
  -V, --version                   print program version
  -J{X}                           pass option X to underlying Java VM

Notes:
  The -P, -C, -F, -M, and -D options accumulate.
  Example attribute definition:  -C SourceFile=RUH .
  Config. file properties are defined by the Pack200 API.
  For meaning of -S, -E, -H-, -m, -U values, see Pack200 API.
  Layout definitions (like RUH) are defined by JSR 200.

Repacking mode updates the JAR file with a pack/unpack cycle:
    pack200 [-r|--repack] [-opt | --option=value]... [repackedy.jar] y.jar

Use %JAVA_HOME%/bin/pack200 -r -G jartostrip.jar

Usage:  pack200 [-opt... | --option=value]... x.pack[.gz] y.jar

Packing Options
  -g, --no-gzip                   output a plain *.pack file with no zipping
  --gzip                          (default) post-process the pack output with gzip
  -G, --strip-debug               remove debugging attributes while packing
  -O, --no-keep-file-order        do not transmit file ordering information
  --keep-file-order               (default) preserve input file ordering
  -S{N}, --segment-limit={N}      output segment limit (default N=1Mb)
  -E{N}, --effort={N}             packing effort (default N=5)
  -H{h}, --deflate-hint={h}       transmit deflate hint: true, false, or keep (default)
  -m{V}, --modification-time={V}  transmit modtimes: latest or keep (default)
  -P{F}, --pass-file={F}          transmit the given input element(s) uncompressed
  -U{a}, --unknown-attribute={a}  unknown attribute action: error, strip, or pass (default)
  -C{N}={L}, --class-attribute={N}={L}  (user-defined attribute)
  -F{N}={L}, --field-attribute={N}={L}  (user-defined attribute)
  -M{N}={L}, --method-attribute={N}={L} (user-defined attribute)
  -D{N}={L}, --code-attribute={N}={L}   (user-defined attribute)
  -f{F}, --config-file={F}        read file F for Pack200.Packer properties
  -v, --verbose                   increase program verbosity
  -q, --quiet                     set verbosity to lowest level
  -l{F}, --log-file={F}           output to the given log file, or '-' for System.out
  -?, -h, --help                  print this message
  -V, --version                   print program version
  -J{X}                           pass option X to underlying Java VM

Notes:
  The -P, -C, -F, -M, and -D options accumulate.
  Example attribute definition:  -C SourceFile=RUH .
  Config. file properties are defined by the Pack200 API.
  For meaning of -S, -E, -H-, -m, -U values, see Pack200 API.
  Layout definitions (like RUH) are defined by JSR 200.

Repacking mode updates the JAR file with a pack/unpack cycle:
    pack200 [-r|--repack] [-opt | --option=value]... [repackedy.jar] y.jar
思念满溢 2024-08-28 19:53:40

Proguard 有压缩字节码的选项。

Proguard has options for shrinking bytecode.

誰ツ都不明白 2024-08-28 19:53:40

在移动世界中部署时,通过某些混淆工具运行整个 jar 文件是很常见的。

这样做的主要用途不是增加反编译的难度,而是大大减小 jar 的大小。

混淆工具已经实现了许多减少 jar 大小的步骤:

  • 将所有存储的标识符缩短到尽可能少,
  • 剥离所有调试信息和非必要属性
  • ,甚至可能重写字节码以使用更少的空间

When deploying in the mobile world, it is pretty common to run the entire jar file through some obfuscation tool.

The primary use of this is not to make decompilation harder, but to greatly reduce the size of the jar.

Obfuscation tools already implement many steps that reduce the size of your jar:

  • shortening all stored identifiers to as little as possible
  • stripping all debug information and non-essential attributes
  • possibly even rewriting bytecode to use less space
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文