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

Cannot exclude native method #157

Open
thanhminh-vht opened this issue Aug 13, 2024 · 3 comments
Open

Cannot exclude native method #157

thanhminh-vht opened this issue Aug 13, 2024 · 3 comments

Comments

@thanhminh-vht
Copy link

yGuard currently doesn't have a way to specify the shrinker to keep all native method. This make shrinking some fat jar that include native libraries (e.g. Eclipse SWT) nearly impossible.

So my question is:

  • Could this feature be implemented?
  • If yes, how hard would it be to implement this? What's needed to be done?
@thomasbehr
Copy link
Member

While I cannot answer your questions (I simply do not know), the general advice on shrinking is: Do not.
Shrinking is a legacy feature that is almost useless with modern day internet band widths and disk storage sizes while at the same time it is very difficult to setup correctly. (It typically requires manual configuration that is hard to get right even for yGuard experts.) It is not worth the effort.

@Fohlen
Copy link
Member

Fohlen commented Jan 30, 2025

@thanhminh-vht sorry for being late to the party. Looking at the source code here, it shouldn't be that hard.

One could add a setting to the shrinker and then check for the corresponding opcode:

        if ((access & Opcodes.ACC_NATIVE) != 0) {
           continue;
        }

If this is something you are interested in we are open to a merge request for this feature, otherwise we would close this ticket. Wdyt?

@yGuy
Copy link
Member

yGuy commented Jan 30, 2025

The problem is that as soon as native methods are involved, the shrinker will not be able to analyze them and might remove dependent code. But yeah, if you do it all manually, that would work. But then again, you can just keep the manual methods by hand - as you need to go through them one by one either way to make sure they will still work after the shrinking.

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

4 participants