混淆包含注释的类

发布于 2025-01-01 22:12:47 字数 174 浏览 0 评论 0原文

混淆 .class 文件时,注释将被删除。有没有办法混淆这些文件(包含注释的文件)而不删除它们。如果可能的话,有没有办法混淆未编译的 .java 文件以保留注释?


java编译器如何处理注释以及它们保存在哪里?为什么混淆后所有注释都被删除。在混淆类之后,我不能带回注释并将它们放回到原来的位置以便工作吗?

When obfuscating .class files annotations are removed. Is there a way to obfuscate these files(files containing annotations) without removing them. Is there a way to obfuscate non compiled .java files to preserve annotations, if it's possible?


How does java compiler treat annotations and where are they preserved? why after obfuscation all the annotations are removed. Can't I, after obfuscating the classes, bring back the annotations and put them back in their place in order to work?

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

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

发布评论

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

评论(2

吹梦到西洲 2025-01-08 22:12:47

我询问并研究了注释和混淆,我发现了以下内容:

  1. 注释保留在类字节码的元部分中
    并且很难操纵它们。混淆程序不处理此类
  2. 我已经尝试了很多混淆器 - 商业和开源
    ,但是它们都不能混淆带有注释的类
    它们的所有字段和方法都已注释
  3. 我能想到的唯一方法是使用配置的 xml
    文件而不是注释

I asked and researched on annotations and obfuscation and I've found the following:

  1. Annotations are kept in the meta section of the class byte-code
    and it's very hard to manipulate them. Obfuscation programs don't deal with such classes
  2. I have tried a lot of obfuscators - commercial and opensource
    ones, but neither of them could obfuscate annotated classes that have
    all of their fields and methods annotated
  3. The only way left that I could think of is to use xml configured
    files instead of annotations
慈悲佛祖 2025-01-08 22:12:47

我们通常使用 proguard 混淆已经编译的类,我可以肯定,不可能混淆未编译的 . java 文件,因为它正在处理字节码本身。

要保留注释,您可以告诉 proguard 保留注释等特定属性。您可以在示例章节中找到更多信息。我建议使用 proguardGui 为混淆过程构建您自己的配置文件。

We generally obfuscated already compiled classes with proguard and I am kind of sure, it's not possible to obfuscate non compiled .java files, since it's working on the byte-code itself.

To keep your annotations, you can tell proguard to keep specific attributes like annotations. You can find more information in their example chapter. I recommend using proguardGui to build your own configuration file for the obfuscation-process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文