Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard of field type, method return type and method parameters in conditional rules can't be referenced #385

Open
zerny opened this issue Jan 30, 2024 · 0 comments

Comments

@zerny
Copy link

zerny commented Jan 30, 2024

When writing a conditional rule with a wildcard pattern in place of types in member patterns, it is not possible to back-reference it. It appears that the wildcard is simply skipped and subsequent wildcards are then off by one.

Consider the program:

package com.example;
public class A {
  public int foo() { ... }
  public int foo(int x) { ... }
}

The following rule will not work:

-if class **A { *** foo(); } -keep class <1>A { <2> foo(<2>); }

in contrast to:

-if class **A { *** foo(); } -keep class <1>A { int foo(int); }

Also, the following rule shows how the index is offset by one as it will apply and keep the one-arg foo if the zero-arg foo is used:

-if class **A { *** *(); } -keep class <1>A { int <2>(int); }

but the rule that would match the number of wildcards fails with an index error:

-if class **A { *** *(); } -keep class <1>A { int <3>(int); }

The same issue applies to:

  • the return-type of fields as in { *** x; }
  • the indexed method parameters as in { void foo(int, ***, int); }
  • the "any" method parameters as in { void foo(...); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant