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

2

5

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

enter image description here 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?

Karakorum answered 27/9, 2013 at 0:59 Comment(5)
An interesting question, to be sure, but kind of a "guess what they were thinking" type question, which may not be appropriate for this site.I
This question appears to be off-topic because it is about mind reading Java devs.Seals
Maybe for a nchor like in HTML.Averir
@SotiriosDelimanolis Maybe, but how is "anchor" related to object references?Karakorum
Heck, if I know... In HTML it's taken more to mean a hyperlink. I guess you could view references like that.Averir
H
3

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.

Hugohugon answered 27/9, 2013 at 18:14 Comment(2)
Very true, I hadn't thought of that; I simply popped the table off of Wikipedia. I really like the idea of a meaning address, as an object reference essentially refers to a memory address.Karakorum
Good point that the implied letter for references is A in instructions.Operon
H
1

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

Haematogenous answered 27/9, 2013 at 1:24 Comment(1)
Great idea, it's definitely reasonable for the use of r to be avoided in favor of returnAddress.Karakorum

© 2022 - 2024 — McMap. All rights reserved.