For what it's worth, here is the Proguard configuration I've used to 
prevent removal of required CGLIB components:

# Referenced by ReflectUtils.newInstance
-keepclassmembers class com.google.inject.cglib.reflect.FastClass
{
    <init>(java.lang.Class);
}

# Referenced by com.google.inject.cglib.proxy.Enhancer.getCallbacksSetter
-keep class com.google.inject.cglib.proxy.MethodProxy
{
    *;
}

# Referenced by cglib-enhanced proxies
-keep class com.google.inject.cglib.core.ReflectUtils
{
    public <methods>;
}

# Referenced by cglib proxies
-keep class com.google.inject.cglib.proxy.MethodInterceptor
{
    public java.lang.Object intercept(java.lang.Object, 
java.lang.reflect.Method, java.lang.Object[], 
com.google.inject.cglib.proxy.MethodProxy);
}

Gili

Stuart McCulloch wrote:
> 2008/10/27 Stuart McCulloch <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>
>     2008/10/27 Stuart McCulloch <[EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>>
>
>         based on a quick hack of the Guice codebase to switch to reduced
>
>         versions of Maps, Lists, etc. (as the number of statics used
>         is small)
>         we could shrink the jar to at least 600k, ie. a saving of 30%
>
>         hmm, I might take a peek at hacking JarJar to do this :)
>
>
>     FYI, I tried switching to use proguard but I couldn't find a way
>     to make
>     proguard rename the packages but keep the original class names :(
>
>
> I've opened an issue to track this:
>
>    http://code.google.com/p/google-guice/issues/detail?id=264
>
> ProGuard obfuscation doesn't play well with CGLIB, and adapting
> JarJar to trim static methods is non-trivial in the current codebase
> so IMHO combining the two in "build.xml" is the best option...
>  
>
>     but you can use it to strip unused static methods and then use jarjar
>     to rename the packages (see patch below) - though it would be cool
>     if we could get jarjar to do all of this...
>
>     the final guice jar after proguard'ing and jarjar'ing is ~600k
>
>     -- 
>     Cheers, Stuart
>
>
>     Index: build.xml
>     ===================================================================
>     --- build.xml   (revision 649)
>     +++ build.xml   (working copy)
>     @@ -11,15 +11,30 @@
>
>        <target name="jar" depends="compile, manifest"
>             description="Build jar.">
>     +    <taskdef resource="proguard/ant/task.properties"
>     +      classpath="lib/build/proguard.jar"/>
>          <taskdef name="jarjar"
>     classname="com.tonicsystems.jarjar.JarJarTask"
>            classpath="lib/build/jarjar-1.0rc8.jar"/>
>          <mkdir dir="${build.dir}/dist"/>
>     +    <proguard>
>     +      -libraryjars ${java.home}/lib/rt.jar
>     +      -libraryjars ${ant.home}/lib/ant.jar
>     +      -libraryjars lib/aopalliance.jar
>     +      -injars ${build.dir}/classes
>     +      -injars lib/build/cglib-2.2.jar(!META-INF/**)
>     +      -injars lib/build/asm-3.1.jar(!META-INF/**)
>     +      -injars
>     lib/build/google-collect-snapshot-20080530.jar(!META-INF/**)
>     +      -outjars ${build.dir}/stripped.jar
>     +      -keep class com.google.inject.** { *; }
>     +      -keepclassmembers class !com.google.common.** { *; }
>     +      -keepattributes
>     +      -dontobfuscate
>     +      -dontoptimize
>     +      -dontnote
>     +    </proguard>
>          <jarjar jarfile="${build.dir}/dist/guice-${version}.jar"
>              manifest="${build.dir}/META-INF/MANIFEST.MF">
>     -      <fileset dir="${build.dir}/classes"/>
>     -      <zipfileset src="lib/build/cglib-2.2.jar"/>
>     -      <zipfileset src="lib/build/asm-3.1.jar"/>
>     -      <zipfileset
>     src="lib/build/google-collect-snapshot-20080530.jar"/>
>     +      <zipfileset src="${build.dir}/stripped.jar"/>
>            <rule pattern="com.google.common.**"
>     result="[EMAIL PROTECTED]"/>
>            <rule pattern="net.sf.cglib.**"
>     result="[EMAIL PROTECTED]"/>
>            <rule pattern="org.objectweb.asm.**"
>     result="[EMAIL PROTECTED]"/>
>
>
>
>
> -- 
> Cheers, Stuart
>
> >

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to