Question

Is there any way to query the name of the current method if you've obfuscated your code? I'm asking because there are times when I want to log a message with the executing method as a prefix.

Was it helpful?

Solution

Just add the method name directly to the string you are outputting. If you get the name of the current method via reflection, it will be the obfuscated name. If it was not this way, anybody would be able to figure out the original method, defeating the obfuscation (or dramatically hampering it).

OTHER TIPS

Alternatively, obfuscation tools are supposed to be able to output their own obfuscation logs so you can write a tool to translate your application's obfuscated logs into something human-readable.

Of course, once you get there, development versions of your application could include the ability to access their own obfuscation logs and translate the result of reflection before they output logs.

You can have obfuscation logs on the file system, as an application resource in the jar file or download them from a remote server.

If you only keep decrypted obfuscation logs in your application memory, the VM sandbox is supposed to keep them fairly safe.

Please reconsider why you want to obfuscate. The things an obfuscator obfuscates is frequently those useful for debugging.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top