反编译后的一些语法问题
我最近不得不反编译一个项目的.class 文件。反编译器工作得很好,除了现在在代码中我有这些奇怪的小片段:
break MISSING_BLOCK_LABEL_666;
Exception exception;
exception;
不过我注意到其中的一个模式,它似乎出现在代码中“catch”语句的右大括号之后。然而,我并没有出现在每一个 catch 语句之后......但这是值得怀疑的事情。
如果有人在反编译后遇到此类问题或只是知道为什么会发生这种情况,我将非常感谢您的帮助!
如果您需要更多信息,请随时询问...
I recent had to decompile a projects .class files. The decompiler worked pretty well, except now in the code I have these weird little snippets:
break MISSING_BLOCK_LABEL_666;
Exception exception;
exception;
I have noticed a pattern in it though, it seems to appear right after the closing brace of 'catch' statements in the code. I does not however appear after each and every catch statement... But it's something to wonder about.
If anyone has had this type of problem after decompiling or just an idea of why this would happen, I would really appreciate some help!
Please don't hesitate to ask in case you need more info...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道这个具体情况,但是Java编译器做了很多改进和优化。因此,如果您反编译这些类,您将看到此优化而不是原始代码。编译器解决了“语法糖”(特殊的代码形式,使您的生活更轻松),我认为您的问题是这样的。例如:您在代码中使用的每个公共静态最终都将解析为反编译代码中的值(如 Integer.MAX_INT),或带有迭代器的 for 循环(
for foo f: foos
)将在其他事情上解决。只需查看反编译的枚举器即可。您不能依赖反编译器为您提供某人编写的确切代码,而是为您提供编译器优化过的代码。
I dont know this particular case, but the Java Compiler does a lot of improvements and optimizations. So if you decompile the classes, you will see this optimizations instead of the original Code. The Compiler resolves "Syntactic Sugar" (Special code forms which make your life easier), and i think your problem is something like that. For Example: every public static final you use in your code will be resolved to its value in the decompiled Code (like Integer.MAX_INT), or for-loops with an iterator (
for foo f: foos
) will be resolved in something else. Just look at an decompiled Enumerator.you cant rely on the decompiler to give you the exact code, soeone has written, but to give you the code the Compiler has optimized.
您的类是使用 JDK 7 编译的吗? Java 7 改进/扩展了
try
和catch
子句。即使不使用新语法,编译器生成的代码也可能与以前略有不同。这可能足以让反编译器感到困惑。Have your classes been compiled using JDK 7? Java 7 has improved/extended the
try
andcatch
clauses. The compiler might generate the code a little bit differently than before even when the new syntax is not used. That might be enough to baffle the decompiler.