尽管混淆了真实的运行时方法名称?
如果您混淆了代码,有什么方法可以查询当前方法的名称吗? 我这么问是因为有时我想记录一条以执行方法为前缀的消息。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需将方法名称直接添加到您要输出的字符串中即可。 如果通过反射获取当前方法的名称,它将是混淆后的名称。 如果不是这样,任何人都能够找出原始方法,击败混淆(或极大地阻碍它)。
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).
或者,混淆工具应该能够输出自己的混淆日志,以便您可以编写一个工具将应用程序的混淆日志转换为人类可读的内容。
当然,一旦到达那里,应用程序的开发版本可能包括访问自己的混淆日志并在输出日志之前转换反射结果的能力。
您可以将混淆日志作为 jar 文件中的应用程序资源存储在文件系统上,或者从远程服务器下载它们。
如果您仅将解密的混淆日志保留在应用程序内存中,则虚拟机沙箱应该可以保证它们相当安全。
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.