Why is 'a' the Java bytecode prefix for object references? [closed]

…衆ロ難τιáo~ 提交于 2019-12-10 15:05:08

问题


Type-specific Java bytecode instructions have single-character prefixes to specify the type that the instruction relates to.

Taken from Wikipedia's entry on Java bytecode

In each case, the prefix choice makes sense, consisting of the first letter of the type (except boolean, which doesn't have an instruction prefix). The object reference prefix, however, does not seem logical, seeing as both o and r (the two first-letters) are free. Instead, object reference instructions use a as their prefix.

Why are object reference bytecode instructions prefixed with a, rather than the seemingly more appropriate o or r?


回答1:


That table is questionable. There is no byte code instruction dealing with boolean thus there is no instruction name starting with “z”. The “z” might come from type signatures where Z stands for boolean but that’s not the same as for type signatures J stands for long and L starts a class name. So there’s no consistency there. For instructions “a” might stand for address as astore instructions are able to store return addresses into a local variable too. Maybe, at an earlier time more of these a… instructions were able to deal with addresses other than objects and that has been limited later.




回答2:


It might be because r refers to the type returnAddress which is used internally by the JVM.



来源:https://stackoverflow.com/questions/19041106/why-is-a-the-java-bytecode-prefix-for-object-references

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!