[英]Can ProGuard change access modifers to package-private?
Is it possible, using ProGuard, to move all your obfuscated classes to a named package and change their public or protected methods or member variables to package protected? 是否可以使用ProGuard将所有混淆的类移动到命名包,并将其公共或受保护的方法或成员变量更改为受保护的包?
I know you can use -repackageclasses to move the classes, but it seems -allowaccessmodification changes access modifiers to public. 我知道您可以使用-repackageclasses移动类,但是-allowaccessmodification似乎将访问修饰符更改为public。 The goal is to prevent users of my library from being able to use anything but the exposed public API.
目的是防止我的图书馆用户只能使用公开的公共API之外的任何东西。 Any help is appreciated.
任何帮助表示赞赏。
Edit: I meant package-private not package-protected. 编辑:我的意思是包私有而不是包保护的。
I don't think you can, and I don't think you should. 我认为您不能,我也不应该。 When classes are compiled and code won't change, relaxing the object/method qualifiers won't alter access patterns;
当类被编译并且代码不会改变时,放宽对象/方法限定符不会改变访问模式。 in other words, an object that successfully called a
protected
method/object would still have access to it if the qualifier is changed to public
. 换句话说,如果将限定符更改为
public
,则成功调用protected
方法/对象的对象仍然可以访问它。 The opposite is not true; 相反的事实是不正确的。 a
public
object/method that turns protected
could become invisible/inaccessible to the calling object all of a sudden - rendering badly compiled code. 变成
protected
的public
对象/方法可能突然变得对调用对象不可见/不可访问-导致编译不良的代码。 I have used ProGuard before, but my answer is based on logic rather than experimentation. 我以前使用过ProGuard,但是我的回答是基于逻辑而不是实验。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.