如果源代码在不同目录中编译,则编译器输出(.class 文件)会有所不同
我遇到以下问题:在编译某些类集时,如果在不同目录中执行编译,则会生成不同的 .class 文件。生成的.class文件之间的差异如下:
1)版本:
1062: aload_3
1063: invokevirtual <some_method>
1066: goto 1078
1069: astore 15
1071: aload_3
1072: invokevirtual <some_method>
1075: aload 15
1077: athrow
1078: aload_3
1079: areturn
2)版本:
1062: jsr 1076
1065: goto 1084
1068: astore 15
1070: jsr 1076
1073: aload 15
1075: athrow
1076: astore 16
1078: aload_3
1079: invokevirtual <some_method>
1082: ret 16
1084: aload_3
1085: areturn
以上代码具有相同的执行逻辑。不幸的是,我必须解释为什么编译器会这样做。奇怪的是,有时即使在同一目录、同一源中编译,连续编译之间也会出现差异(总是相同,上面提到过)。
知道会发生什么吗? 预先感谢您的回复!
I have the following problem: While compiling some set of classes different .class files are generated if compilation was executed in different directories. The diff between generated .class files is following:
1) version:
1062: aload_3
1063: invokevirtual <some_method>
1066: goto 1078
1069: astore 15
1071: aload_3
1072: invokevirtual <some_method>
1075: aload 15
1077: athrow
1078: aload_3
1079: areturn
2) version:
1062: jsr 1076
1065: goto 1084
1068: astore 15
1070: jsr 1076
1073: aload 15
1075: athrow
1076: astore 16
1078: aload_3
1079: invokevirtual <some_method>
1082: ret 16
1084: aload_3
1085: areturn
Above code has the same execution logic. Unfortunately, I have to have explanation why the compiler behaves this way. What is strange, sometimes even when compiling in the same directory, the same sources, a difference between consecutive compilations occurs (always the same, mentioned above).
Any idea what happens?
Thanks in advance for response!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该类是否使用任何具有包级范围的方法或类?这可以解释任何差异。
Does the class use any methods or classes which have package level scope? This could account for any differences.