Skip to main content

Obfuscate

6 replies [Last post]
hooligancat
Offline
Joined: 2009-10-20

I am looking into the various tools for obfuscation. Proguard looks to be a good option and in my prelim tests works ok. Are there any recommended obfuscators for bd-j or alternatively any know issues when using proguard?

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vinaykagarwal
Offline
Joined: 2006-01-14

Here is my ant obfuscate task





-libraryjars ${bdj.classes}
-injars ${build.dir}/preobfuscate
-outjars ${build.dir}/classes
-microedition
-dontusemixedcaseclassnames
-optimizationpasses 3
-allowaccessmodification
-keep public class * extends javax.tv.xlet.Xlet
-printmapping ${build.dir}/Xlet.map
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

hooligancat
Offline
Joined: 2009-10-20

Thanks billf and vinaykagarwal. I will try your builds.

dleskov
Offline
Joined: 2003-06-27

My article on Java code protection has pointers to a handful of actively maintained free and commercial obfuscators. I regret I do not know much about BD-J, so you may need to ask the vendors if they support it and/or if there are any special steps involved.

vinaykagarwal
Offline
Joined: 2006-01-14

I use Proguard and it seems to do a pretty good job. I have inspected the obfuscated code many times and it does exactly what I would expect.

hooligancat
Offline
Joined: 2009-10-20

Thanks.

Would you mind sharing the settings that you are using, or alternatively your config file (which I am using through an ant build)?

billf
Offline
Joined: 2004-02-13

Here are the proguard settings I've used. I haven't tested these on tons of players or anything, but they work for the ten or so I happen to have put the disc in. The last line that turns off some of the optimizations was the hard one -- it was one of those trial-and-error binary search things to figure out that this is what works.

billf$ cat build-proguard-args.txt
-target 1.3
-overloadaggressively
-repackageclasses ''
-allowaccessmodification
-printseeds
-keep public class * implements javax.tv.xlet.Xlet
-keep public class * implements com.hdcookbook.grin.Director
-keep public class * implements com.hdcookbook.grin.GrinXHelper
-verbose
-dontpreverify
-optimizations !method/marking/private, *
billf$

I haven't completely integrated this into my ant build the right way, but here's how I invoke it:


failonerror="true"/>











billf$ cat ~/bin/proguard
#!/bin/sh
/Users/billf/lib/proguard4.5beta1/bin/proguard.sh $*
billf$

Doing this with a GRIN-based xlet compresses things down nicely, and makes them run measurably faster. The resulting JAR is a bit over half the original JAR size -- it goes from 112832 bytes to 68987 on a moderately complex project, which is a 39% reduction in size. The final xlet has 65 classes (down from 70), and given the class load time on a BD player, keeping things down to this size range is something I would recommend.

Cheers,

Bill