Menu

#109 Extend 'keepattributes' option by class/method filter

open
None
7
2017-09-21
2011-01-11
No

When specifying the option '-keepattributes Exceptions' all methods in all classes will keep their exception attributes.
Keeping the attributes for all classes in the library increases the size even though there is only one class for public use.
It does not seem to be possible to combine the option '-keepattributes' with a class or method name filter.
A more simple solution would be an option to keep attributes only for non obfuscated classes and methods.

Discussion

  • Eric Lafortune

    Eric Lafortune - 2011-01-11

    You're right; that would have some use. I've mainly been thinking about a proper syntax to specify this, and I'm still not sure. For instance:
    -keepattributes Exceptions public class * { public <methods>; }
    Or the other way around:
    -keep class * { public <methods> [Exceptions]; }

    Only keeping optional attributes for non-obfuscated elements would be insufficient; for instance, line numbers are useful in obfuscated methods too (with a mapping file).

     
  • Eric Lafortune

    Eric Lafortune - 2011-01-11
    • assigned_to: nobody --> lafortune
    • priority: 5 --> 7
     
  • Stefan Martin

    Stefan Martin - 2011-01-11

    Both of your suggestions have their advantages:

    1. Is closer to the existing keep options.
    2. Can be used in all keep rules and can be combined with existing entries (avoids redundant keep entries for a single class or method). A mix of different attributes for different methods is possible in a single statement.

    I would say that 2. is the better choice.
    What about providing both possibilities?

     
  • Ralph

    Ralph - 2012-07-03

    This would also be very useful for interfaces to my library - syntax option 2 would work nicely for me.

    Any ideas for a workaround in the meantime? Thanks.

     
  • James

    James - 2017-09-21

    It would also be useful to have something similar for Annotations. They can often expose a lot of information that you don't want to expose in some environments (e.g. client side). It would be good to be able to filter which Annotation classes to keep the Annotation attributes for, rather than the current all-or-nothing approach.

     

Log in to post a comment.