Link to home
Start Free TrialLog in
Avatar of lcor
lcor

asked on

Proguard Top Level Obfuscation

Hopefully, I can find someone with some Proguard JAVA obfuscation experience.

Here's their website, http://proguard.sourceforge.net/

I have a java servlet application with a directory structure as follows:

servletA.java
servletB.java
somepackage/ACode.java
somepackage/BCode.java
anotherpackage/CCode.java

I'm finding when I run proguard on this application using ant and specify the directory at this level, the obfuscated output jar file looks like this.

servletA.java
servletB.java
x/A.class
x/B.class
x/C.class

That is, the top level servlets don't get obfuscated. I've attached the proguard configuration file.
Does anyone know how to configure proguard to obfuscate the top level servlets?

x comes from the defaultpackage specification in the configuration file.




-injars '..\app.jar'
-outjars '..\o_app.jar'
 
-libraryjars '..\lib\rt_6_0.jar'
-libraryjars '..\lib\servlet-api.jar'
 
-defaultpackage x
-verbose
 
# Keep - Servlets. Keep all extensions of javax.servlet.Servlet.
-keep public class * extends javax.servlet.Servlet
 
# Also keep - Enumerations. Keep a method that is required in enumeration
# classes.
-keepclassmembers class * extends java.lang.Enum {
    public **[] values();
}
 
# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembernames class * {
    native <methods>;
}
 
#Javascript classes
-keepnames class netscape.javascript.JSObject
-keepnames class netscape.javascript.JSException
 
# Remove debugging - Throwable_printStackTrace calls. Remove all invocations of
# Throwable.printStackTrace().
-assumenosideeffects public class java.lang.Throwable {
    public void printStackTrace();
}
 
# Remove debugging - All Log4j API calls. Remove all invocations of the
# Log4j API whose return values are not used.
-assumenosideeffects public class org.apache.log4j.** {
    <methods>;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lcor
lcor

ASKER

I figured moving to a package was what I needed to do but was *hoping* otherwise.
we teach our students and web developers to always use packages. Avoids all the gotchas encountered when using the default package.
Good to hear you got it sorted :)