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

Keep rule does not keep dependencies #55

Open
patrick-premont opened this issue Feb 28, 2024 · 0 comments
Open

Keep rule does not keep dependencies #55

patrick-premont opened this issue Feb 28, 2024 · 0 comments

Comments

@patrick-premont
Copy link
Contributor

patrick-premont commented Feb 28, 2024

From help.txt

The keep rule marks all matched classes as "roots". If any keep rules are defined all classes which are not reachable from the roots via dependency analysis are discarded when writing the output jar. This is the last step in the process, after renaming and zapping.

KeepProcessor.java and Shader.scala have diverged from these semantics and now only keep the classes that match a keep rule.

The code to build the dependency graph and compute its transitive closure is still present but the way it is currently used it has no effect:

  • getExcludes computes the transitive closure but is called before the dependency graph is populated (by depend.put() in KeepProcessor.process() and KeepProcessor.map()), it always returns an empty set. The check here is redundant because excludes is empty, and also because:
  • KeepProcessor.process() now returns false when keep rules don't match, dropping classes even if they are dependencies (that was not the case in the original implementation).
  • JJProcessor.strip() is intended to perform another pass to remove all excluded classes (not seen in the transitive closure). That method still exists but is not called from Shader. (It was called in Main.process())

The path forward depends on what are the intended semantics. To me keeping dependencies in the jar seems more useful and robust, but I do not have an immediate need keep rules. Maybe they are only rarely used. Users who would like to perform dead code elimination could prefer another tool that can also do it at a finer grain than the class level.

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