Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8736853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:23:11+00:00 2026-06-13T10:23:11+00:00

I’m having trouble obfuscating a java library with yGuard . A part of this

  • 0

I’m having trouble obfuscating a java library with yGuard. A part of this library is supposed to be an implementation of a Service Provider Interface (SPI) and as such needs to be excluded from the obfuscation process. The non-obfuscated version of the application which uses this library works without problems. However after obfuscation process, it doesn’t.

I suspect this to be due to an improperly set <shrink> element of yGuard’s ANT task – it probably removes some methods since they are considered as unused. I made sure that the package and the classes are excluded within the renaming phase of obfuscation (<rename>) so that shouldn’t be the cause of the problem.

I had hoped that I could avoid shrinkage of the SPI implementation by specifying the only method required to be implemented by the main interface I’m implementing as an entry point for the shrink engine, but have failed. This method then delegates to other interface implementations so I expected the entire thing to be walked around. See what I have below:

<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"/>
        <method name="org.relaxng.datatype.DatatypeLibrary createDatatypeLibrary(java.lang.String)" class="package.path.to.my.implementation.of.DatatypeLibraryFactory"/>
        <class classes="public"/>
    </keep>
</shrink>

<rename mainclass="package.path.to.main.Class" logfile="obfuscate_rename_log.xml" replaceClassNameStrings="true">
    <property name="error-checking" value="pedantic"/>
    <keep>
        <class name="package.path.to.my.implementation.of.DatatypeLibraryFactory"/>
        <class name="package.path.to.my.implementation.of.DatatypeLibrary"/>
        <class name="package.path.to.my.implementation.of.Datatype"/>
    </keep>
</rename>

I’m implementing a set of org.relaxng.datatype interfaces. They can be invoked through SPI with Jing.

How can I specify an entire package to be excluded from the obfuscation process (both rename and shrink) with yGuard?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:23:12+00:00Added an answer on June 13, 2026 at 10:23 am

    After carefully reading yGuard’s documentation I realized what I did wrong (well not wrong, what I was missing). If you do what I did in the question it will cause the shrink engine to keep the methods you specify, but it will not keep the constructor of the class which will then cause SPI to fail to instantiate your implementation.

    The following needs to be done:

    <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>
    </shrink>
    
    <rename mainclass="package.path.to.main.Class" logfile="obfuscate_rename_log.xml" replaceClassNameStrings="true">
        <property name="error-checking" value="pedantic"/>
        <keep>
            <class name="package.path.to.my.implementation.of.DatatypeLibraryFactory"/>
        </keep>
    </rename>
    

    This will leave the public API of a specific class out of obfuscation shrinking and renaming. You only need to leave out the part which enables your service provider implementation to be instantiated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.