Menu

#178 Allow to keep another class, method or field on mark-usage of another class or member

Some sunny day
open
None
5
2017-11-14
2016-03-31
No

Assume you have a class "A" with method "X" that dynamically loads class "B". I did not find a way to specify 'keep class "B" if method "A.X" is kept' in the current ProGuard configuration.

It would furthermore be helpful to specify such rules also by using annotations.

class A {
@KeepOtherClass(classname="B")
public X() {
...
}
}

Other helpful annotations might be:
@KeepOtherMethod(classname="B", methodname="Y")
@KeepOtherField(classname="B", fieldname="z")

Feel free to choose your own syntax for configuration file and annotations.

Thanks in advance,
Stefan

Discussion

  • Adam K.

    Adam K. - 2017-11-14

    I was trying out the 6.0 beta with a rule like:

    -if class Foo {
        void foo1();
        void foo2();
    }
    -keep class Bar
    

    Where foo1() and foo2() both reflect on Bar. I was expecting "if foo1() OR foo2()" symantics, but it's "if foo1() AND foo2()" symantics. Is this intentional? Could it be the OR symantics instead?

     
    • Eric Lafortune

      Eric Lafortune - 2017-11-14

      The semantics are AND indeed, just like with -keepclasseswithmembers. You can get the OR semantics by specifying multiple -if/-keep options.

       

Log in to post a comment.