When obfuscating all the methods within classes proguard seems to promote all methods to public!
I have a class which contains both public, protected and private methods.
I want to obfuscate most of the code, but there are a few protected and public methods I want to be left unobfuscated, so that I can later link against the obfuscated code and extend the class, overriding one or two of the protected methods.
I use the following keep statment:
-keep 'public class package1.class1.** {public protected *;}'
to keep all the protected and public methods of that class.
However when I look at the resulting jar file I see that all the class methods have become public! This means my new code which a want to build (and write) at a later date can't compile with protected methods.
Should the access type of class should be kept the same as the source?
Logged In: YES
user_id=555208
This is caused by the option -defaultpackage, not by -keep.
Cfr. the ProGuard manual.
Logged In: YES
user_id=1446066
Ok, I remove -defaultpackage and yes the protected functions remain protected.
But, we Have a large appplication of which a small part needs to be un-ofuscated so that we can latter link in extensions. But to hide the meaningfull names of the rest of the applications packages we need to use -defaultpackage.
However for the classes and packages which are kept using -keep statements I don't see why the protected methods need be converted to public.
So what I'm suggesting is that for all class that get moved into the default package then the protected methods should be made public, but packages and classes which are kept then the protect methods should remain protected.
Logged In: YES
user_id=555208
ProGuard version 4.0 only makes classes and class members
public when necessary (which may still be include methods in
your extension API). As an alternative, this version
provides options to obfuscate package names. Version 4.0
will be released when some other features are completed.