4

For the Jvm field descriptors, as this link says: https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.2

It uses Z to describe boolean type, J for long and L for class instance.

Anyone knows why?

I mean I noticed that B has already used by byte, but why use Z for boolean? why not use L for long and R for reference?

Lang
  • 943
  • 13
  • 33

1 Answers1

3

I am not sure if you will get an authoritative answer, however.

  • J is sometimes used in other contexts to be wider than I as it is the next letter (similarly H for half int/short, or the previous letter to I)
  • L for language data structure?
  • Z for a letter which won't be used for anything else. c.f. Z is used for "Zulu" or GMT time as a default time.

BTW They could have used b for boolean as the JVM is case sensitive.

If you look at the details of the byte code, many choices seem ad hoc, and in hindsight might have been done better, but at the time Java was very new and it wasn't at all clear it would be as popular as it is.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 1
    Thank you for the interesting answer : ) – Lang Mar 12 '19 at 09:18
  • 1
    It’s possible that `L` stands for types requiring **L**inkage whereas `Z` implies operations boiling down to **Z**ero-testing, like “branch if zero” or “branch if non-zero”, but that’s all conjecture… There was a similar discussion in the comment on [this answer](https://stackoverflow.com/a/32768152/2711488) and a related question, [Why is 'a' the Java bytecode prefix for object references?](https://stackoverflow.com/q/19041106/2711488). – Holger Mar 12 '19 at 12:40