Proguard Top Level Obfuscation

Posted on 2009-02-17
Medium Priority
Last Modified: 2013-11-24
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:


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.


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
# 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.** {

Open in new window

Question by:lcor
  • 2
LVL 86

Accepted Solution

CEHJ earned 1200 total points
ID: 23664155
Those top level classes should be in a package anyway, so why not move them into one?
LVL 92

Assisted Solution

objects earned 800 total points
ID: 23664220
> -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


Author Closing Comment

ID: 31548005
I figured moving to a package was what I needed to do but was *hoping* otherwise.
LVL 92

Expert Comment

ID: 23675520
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 :)


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question