Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我们有这样的代码:
class A { private hash = 0; public void test(){ if (hash == 1) { //dosomething } } }
比较究竟在哪里进行?
以下是我的理解:
这样对吗 ?在这个意义上,堆中的哈希可以改变吗?
字段哈希和常量 1 都加载到堆栈上。然后进行比较:
... GETFIELD A.hash : I // push hash onto the stack ICONST_1 // push 1 onto the stack IF_ICMPNE L1 // pop the top two ints off the stack and compare them ... // do smth L1 RETURN