Menu

#710 ProGuard does not adapt WebInitParam values

v6.0
open-works-for-me
None
Medium
2018-06-19
2018-06-18
No

ProGuard version 6.0.3. I have a class with the following annotation:

@WebServlet(
    name = "asd",
    urlPatterns = "/asd/*",
    loadOnStartup = 1,
    initParams = {
        @WebInitParam(name = "services", value = "com.company.SomeService"),
    })

But then, when I run the app, I get an exception:

java.lang.ClassNotFoundException:
com.company.SomeService

Which means that ProGuard did not obfuscate the "value" of the WebInitParam. I have in my configuration:

    adaptclassstrings
    adaptresourcefilenames
    adaptresourcefilecontents 'META-INF/services/*,WEB-INF/web.xml'

Am I doing something wrong or is this not supported?

Discussion

  • Eric Lafortune

    Eric Lafortune - 2018-06-18

    Can you try that configuration without the quotes?

    Also, you may still need to specify to keep the class to begin with:

    -keep,allowobfuscation class com.company.SomeService
    
     
  • Eric Lafortune

    Eric Lafortune - 2018-06-18
    • status: open --> open-works-for-me
     
  • Boris Petrov

    Boris Petrov - 2018-06-19

    Thanks for the response! I'm not sure what you mean by "configuration without the quotes"? What I pasted was Gradle configuration. I also have other settings:

        overloadaggressively
        allowaccessmodification
        mergeinterfacesaggressively
        keepparameternames
        optimizationpasses 5
        dontshrink
        dontusemixedcaseclassnames
        repackageclasses 'com.company'
        optimizations '!code/allocation/variable'
    

    This didn't help:

    keep allowobfuscation: true, 'public class com.company.SomeService'
    

    Only with this configuration it works:

    keep 'public class com.company.SomeService'
    

    However, this is not what I want - I would like the class to be renamed and the string in the @WebInitParam anotation to be modified to match it. Am I doing something wrong or perphaps this is a bug?

     

Log in to post a comment.