Norqy / jarjar

Automatically exported from code.google.com/p/jarjar
0 stars 0 forks source link

Support removal of unused static methods #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
( For background see
http://code.google.com/p/google-guice/issues/detail?id=264 )

The attached patch adds support for removing unused static methods, you can
also use the "keep" rule to flag whole classes or selected methods that you
want kept even if they look unused (like main methods, etc.)

For example, for Guice the following methods look unused but should be kept
around because they are used by generated CGLIB proxy classes:

  <keep pattern="net.sf.cglib.core.ReflectUtils.findMethods"/>
  <keep pattern="net.sf.cglib.proxy.MethodProxy.create"/>

With this patch I can reduce Guice to ~700k (a saving of around 200k).

Feel free to use/modify/rewrite this patch as you feel fit, for example
you'd probably want to add a new flag to make removing methods optional.

Original issue reported on code.google.com by mccu...@gmail.com on 1 Dec 2008 at 5:42

Attachments:

GoogleCodeExporter commented 9 years ago
The keep rule removes classes which can be needed (e.g. yuicompressor needs 
Rhino's Parser1.class which will be removed).

There are many bytecode shrinkers out there, -1 for adding this feature in 
JarJar as too many problems might occur then. If you want to shrink code that's 
not what JarJar is for IMHO.

Original comment by joern.h...@gmail.com on 17 Jun 2011 at 9:18