?
Solved

Proguard Top Level Obfuscation

Posted on 2009-02-17
4
Medium Priority
?
1,830 Views
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:

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

0
Comment
Question by:lcor
  • 2
4 Comments
 
LVL 86

Accepted Solution

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

Assisted Solution

by:objects
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

0
 

Author Closing Comment

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

Expert Comment

by:objects
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 :)

0

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