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

lcorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Those top level classes should be in a package anyway, so why not move them into one?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mick BarryJava DeveloperCommented:
> -keep public class * extends javax.servlet.Servlet

your telling it to keep servlets

which you'd want to do so your config does not break

0
lcorAuthor Commented:
I figured moving to a package was what I needed to do but was *hoping* otherwise.
0
Mick BarryJava DeveloperCommented:
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 :)

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.