Search code examples
javaobfuscationyguard

yguard remove default type constructor


I have some problem with the yguard library when i make an obfuscated jar.

Yguard remove default contructor type like this (no parameters, no visibility) :

   Test(){

   }       

Do you know why it remove this type of constructor ?

And do you have a solution to this problem ?

Thank you,

Best regards,


Solution

  • I believe yGuard removes such constructors because of shrink task. Just exclude your class from shrinking like this (taken from this answer by predi):

    <shrink logfile="obfuscate_shrink_log.xml">
    <property name="error-checking" value="pedantic"/>
    <keep>
        <method name="void main(java.lang.String[])" class="package.path.to.main.Class"/>
        <class name="package.path.to.my.implementation.of.DatatypeLibraryFactory" methods="public"/>
        <class classes="public"/>
    </keep>
    

    Or use techniques described in troubleshooting section of yGuard documentation (http://www.yworks.com/products/yguard/yguard_ant_howto.html#hints).