1

I do obfuscation of my Java code before delivery (currently using ProGuard).

When I "decompile" the obfuscated byte code, obviously all strings are not obfuscated. This is also true for messages in exceptions. These exception messages give the reader a lot of information to understand the code. Like:

if(a == null){
  throw new IllegalArgumentException("SuperSecretObject cannot be null");
}

Is it possible, using ProGuard or another tool to compile while removing all exception message strings?

Else, can you recommend other methods to hide strings which are not functionally necessary?

3
  • Removing exception messages with change the code behaviour.
    – gontard
    Mar 25, 2013 at 8:43
  • 2
    You can move exception messages to a file outside the code, but even then one can always refer to those messages. Mar 25, 2013 at 8:44
  • @Sudhanshu good idea: I could use a Properties which returns "" when a key isn't found. The properties would be populated only on test installation which should have the exception messages.
    – Philipp
    Mar 25, 2013 at 8:47

1 Answer 1

1

For example you could use

throw new IllegalArgumentException(SuperSecretObject.class.getName() + " cannot be null");

Then the the obfuscator can also replace the class name with the obfuscated one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.