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

  • Home
  • SEARCH
  • 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 167821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:20:37+00:00 2026-05-11T12:20:37+00:00

I am looking to obfuscate our Java web app code within our existing Ant

  • 0

I am looking to obfuscate our Java web app code within our existing Ant build script, but am running into problems around unit testing. I am obfuscating the code right after it has been compiled, before it is jar-ed and before the unit tests are ran.

However, if I obfuscate my production code and not my test code, all my tests fail because they are trying to call methods that no longer exist because they have been renamed by the obfuscator. I can mark certain methods to not obfuscate so they can be used by external systems such as our test suite, but since we are shooting for high unit test coverage we will need to mark all of our methods as un-obfuscatable.

If I obfuscate the test classes as well, I run into two problems:

1: The production classes and the test classes get merged into the same output directory and I am unable to exclude the test classes from the production .jar files

2: I cannot run my normal Ant batchtest call:

 <batchtest todir='${basedir}/reports'>       <fileset dir='${basedir}/components/common/build-zkm'>            <include name='**/*Test.class'/>       </fileset>  </batchtest> 

because the obfuscator has changed the names of the tests.

I could just run the obfuscator on the resulting .war/.ear files, but I want to have our unit tests run against the modified code to drive out any bugs caused by the obfuscator.

I am currently working with Zelix KlassMaster, but I am still in the evaluation phase so I would be open to other options if they would work better.

  • 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. 2026-05-11T12:20:37+00:00Added an answer on May 11, 2026 at 12:20 pm

    Can you tell it to run the obfuscator such that it effectively refactors the code including the references from the tests (i.e. when a production name changes, the test code changes its reference) but not to obfuscate the tests themselves (i.e. don’t change the names of the test classes or their methods)? Given previous experience with obfuscators I’d expect that to work.

    So for example, suppose we had unobfuscated source of:

    public class ProductionCode {     public void productionMethod() {} }  public class ProductionCodeTest {     public void testProductionMethod()     {         new ProductionCode().productionMethod();     } } 

    You want to set the options of the obfuscator to make it effectively:

    public class Xyzzy {     public void ababa() {} }  public class ProductionCodeTest {     public void testProductionMethod()     {         new Xyzzy(). ababa();     } } 

    That way your ‘run the tests’ Ant tasks should be able to stay the same, because the API of the tests hasn’t changed – merely the implementation of the methods.

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

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Half a megabyte per JSP is not what I'd usually… May 12, 2026 at 1:12 pm
  • Editorial Team
    Editorial Team added an answer <ul> <li class="1" /> <li class="2" /> <li class="3" />… May 12, 2026 at 1:12 pm
  • Editorial Team
    Editorial Team added an answer If you just want show notification, when user is in… May 12, 2026 at 1:12 pm

Related Questions

I am using pyodbc, via Microsoft Jet, to access the data in a Microsoft
I am looking to use a javascript obfuscator. What are some of the most
Does anybody know of a free flash obfuscator(protector)? All I can find are commercial
I'm working on building a development tool that is written in JavaScript. This will

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.