【发布时间】:2014-05-05 05:13:27
【问题描述】:
我需要自动找到所有确定执行的 java 字节码中的指令。 伪代码中的模拟示例:
x=a; //will be executed for sure
y=b; //will be executed for sure
if(x>y) //will be executed for sure
x++; //might not be executed
else
y++; //might not be executed
k=4; //will be executed for sure
一种可能的解决方案是创建一个控制流图并 在那里找到一条确定的路径。 (图论?) 根据例子:
x=a;
y=b;
if(x>y)
| \
| \
x++; y++;
| /
| /
k=4;
您知道如何找到解决此任务的方法吗?
【问题讨论】:
-
这感觉有点像XY problem。您试图解决的根本问题是什么?
-
您的意思是无条件的而非确定性的。在没有线程的情况下,字节码的执行已经是确定性的了。
-
我不认为这是一个 XY 问题,因为它确实是我必须执行的任务的要求,以保证执行。我在 Antimonys 帖子的回答中对此进行了更详细的解释。
标签: java bytecode instructions deterministic