1

I have been trying ProGuard for last 3-4 days. Since the command line call is going to be pretty lengthy, I am trying with proguardgui.

After I came to know that by default, annotations are removed after obfuscation, I tried -keep option but the output jar did not work.

So next I tried disabling all the processing steps like Shrinking, Obfuscating, Optimizing and generated the jar, still dis not work! I confirmed that the output jar has spring mvc annotation by decompiling classes in output jar.

If I have disabled all the processing steps the output jar should be same as input jar, but I see that when I deploy input jar, annotations are detected, and when I deploy output jar, they don't.

Friends, Your help is sincerely appreciated. If required, I will post the sample code and dependencies to recreated this issue. Thanks! --Nealesh

2015/01/08: Here are the steps I am following:

  1. My jar is say xyz.jar located in C:/test directory.
  2. Deploy xyz.jar with the MVC web app.
  3. Confirm that error log shows:

INFO: Refreshing WebApplicationContext for namespace 'TestDataImport-servlet': startup date [Sun Jan 04 19:37:45 IST 2015]; root of context hierarchy Jan 04, 2015 7:37:45 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/TestDataImport-servlet.xml] Jan 04, 2015 7:37:46 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod INFO: Mapped "{[/dataimportcontroller/setconfig],methods=[POST],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public java.lang.String com.dn.controller.DataImportController.setconfig(java.lang.String[]) Jan 04, 2015 7:37:46 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod INFO: Mapped "{[/dataimportcontroller/insertRegion],methods=[POST],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public void com.dn.controller.DataImportController.insertRegion(java.lang.String) Jan 04, 2015 7:37:47 PM org.springframework.web.servlet.view.ContentNegotiatingViewResolver initServletContext

  1. This implies that the annotation are detected and the annotated method can be called over http.
  2. Start Proguardgui.
  3. On input/Output tab select Add Input and choose the jar file to be obfuscated.
  4. On input/Output tab select Add Output directry and name of the output jar, in my case C:/temp/xyzob.jar.
  5. Click next to go to “Shrinking” tab
  6. Uncheck “Shrink ” check box and click next to go to “Obfuscation” tab.
  7. Uncheck “Obfuscate” check box and click next to go to “Optimise” tab.
  8. Uncheck “Optimise” check box and click next to go to “Information” tab.
  9. Uncheck “Preverify” checkbox and click next to go to “Process” tab.
  10. Click “Process”.
  11. Use Decompiler and confirm that the annotations are preserved in the output jar.
  12. Replace the xyz.jar with xyzob.jar in the mvc web app.
  13. Redeploy web app.
  14. The log is shown as follows.

INFO: Refreshing WebApplicationContext for namespace 'TestDataImport-servlet': startup date [Sun Jan 04 19:33:39 IST 2015]; root of context hierarchy Jan 04, 2015 7:33:39 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/TestDataImport-servlet.xml] Jan 04, 2015 7:33:41 PM org.springframework.web.servlet.view.ContentNegotiatingViewResolver initServletContext

  1. INFO: Mapped messages are not present, which mean annotations are not detected.
  2. My issue is, if I am unchecking all the options, the input and output jars should have same content.
Spyros K
  • 2,480
  • 1
  • 20
  • 37
Nealesh
  • 629
  • 6
  • 12
  • Please mention which exact version of ProGuard and which version of Java you are using. Early v5 ProGuard had severe problems with Java 8. – Hendrik Jan 05 '15 at 09:14
  • ProGuard 5.1 and JDK 1.7. – Nealesh Jan 05 '15 at 12:14
  • To preserve a number of things, but also annotations in particular, I'm using the line: `-keepattributes InnerClasses,SourceFile,LineNumberTable,Deprecated,Signature,*Annotation*,EnclosingMethod,Exceptions`. The asterisks around `Annotation` seem to be essential. See http://stackoverflow.com/questions/7378693/proguard-and-annotations – Hendrik Jan 06 '15 at 10:21
  • You are right, that is supposed to happen, and I see annotations preserved in the output jar but the annotations are not detected, like I said in my query. – Nealesh Jan 07 '15 at 10:14
  • Perhaps posting the exact options that you are using is helpful. – Hendrik Jan 07 '15 at 10:17
  • Hendrik, I have updated the issue now with all the steps I am following. – Nealesh Jan 08 '15 at 13:33

0 Answers0