yGuard icon indicating copy to clipboard operation
yGuard copied to clipboard

Cannot exclude `native` method

Open thanhminh-vht opened this issue 1 year ago • 3 comments
trafficstars

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?

thanhminh-vht avatar Aug 13 '24 17:08 thanhminh-vht

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.

thomasbehr avatar Aug 14 '24 07:08 thomasbehr

@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?

Fohlen avatar Jan 30 '25 13:01 Fohlen

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.

yGuy avatar Jan 30 '25 13:01 yGuy