使用 ProGuard 混淆 Java 受保护元素
我正在开发一个由几个单独的类组成的库,这些类一起工作来执行库的功能。然后,其中一个类公开了一些公共函数,所有外部代码都可以使用该库。
由于不同的类需要交互,我将它们全部放在同一个包中,并且有很多“受保护”的东西(类和函数)。
问题是 ProGuard 默认情况下不会混淆这些受保护的元素,因为它们以后有可能与同一包中的另一个类组合。不过,出于安全原因,我想阻止这种情况发生。
所以问题是,除了私有元素之外,我是否可以强制 ProGuard 混淆这些受保护的元素?
换句话说,有没有办法告诉 ProGuard“我已经向这个包添加了一些东西,请不仅混淆每个类中的私有内容,还要混淆包中受保护的内容”?
谢谢!
I am developing a library that consists of several individual classes that all work together to perform the function of the library. One of the classes then exposes a handful of public functions that all outside code to make use of the library.
Since the different classes need to interact, I put them all in the same package and have a lot of "protected" stuff (classes and functions).
The problem is that the ProGuard by default will not obfuscate these protected elements as there is a chance that they could later be combined with another class in the same package. I would like to prevent this, though, for security reasons.
So the question is, can I force ProGuard to obfuscate these protected elements in addition to the private ones?
To put it another way, is there a way to tell ProGuard "I am done adding stuff to this package, please obfuscate not only the private stuff within each class, but the protected stuff within the package"?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ProGuard 会混淆与配置中的 -keep 选项之一不匹配的所有内容。例如,来自 ProGuard 手册 >示例>典型的库:
该规范保留所有公共和受保护的类、字段和方法。 ProGuard 会混淆其他任何内容。如果您想混淆更多内容,则必须指定要保留的更少元素,例如使用一个或多个选项,如下所示:
您可以使用通配符或其他模板,如 ProGuard 手册中所述。
因此,默认情况下,ProGuard 会混淆所有内容,除非您指定保留某些元素。 ProGuard 无法猜测您想要保留什么。
ProGuard obfuscates everything that isn't matching one of the -keep options in your configuration. E.g., from the ProGuard manual > Examples > A typical library:
This specification keeps all public and protected classes, fields, and methods. ProGuard obfuscates anything else. If you want to obfuscate more, you have to specify fewer elements to keep, e.g. with one or more options like this one:
You can use wildcards or other templates, as documented in the ProGuard manual.
So, by default, ProGuard obfuscates everything, unless you specify to keep some elements. ProGuard can't guess what you'd like to keep.