0

Array type encoding from the API documentation:

boolean             Z
byte                B
char                C
class or interface  Lclassname;
double              D
float               F
int                 I
long                J
short               S 

It seems counterintuitive to introduce J for long, instead of keeping L for long and using T for reference types. I was unable to find a solid explanation of this encoding decision.

To clarify, the Java Language Specification sometimes has comments on syntax features influenced by other languages and similar "external" reasons. I'm looking for that kind of explanation. For instance, my guess for Z is that it is a reference to 0/!0 check in C.

This answer points to the JVM specification, but the explanation for J, L and Z is still out there.

Andrey
  • 2,503
  • 3
  • 30
  • 39
  • What practical reason would it matter what their conventions were? Would it satisfy a real-world problem that you're facing when dealing with or interfacing with these types, leading to some frustration in building software based on this knowledge, or is this to satisfy some fleeting trivia-like curiosity? – Makoto Mar 16 '18 at 20:59
  • https://stackoverflow.com/questions/32768036/why-is-l-the-prefix-for-reference-types-instead-of-some-other-letter#comment53376346_32768036 – shmosel Mar 16 '18 at 21:04
  • @Makoto the practical reason is that I had a question in the certification exam that required knowledge of this encoding. It's easier for me to remember something if I understand the logic behind it. And yes, I'm quite curious about it. – Andrey Mar 16 '18 at 21:10
  • @shmosel that question is about the documentation, my question is about why these letters. – Andrey Mar 16 '18 at 21:12
  • The exam probably wanted you to regurgitate this knowledge. (Kind of why I feel like certifications like that are a waste of time. You're not actually *growing* from knowing something by heart that a few seconds of Googling can't just enlighten you with.) – Makoto Mar 16 '18 at 21:13
  • I was linking to a specific comment echoing @Makoto's. – shmosel Mar 16 '18 at 21:17
  • @shmosel oh, I see now. Yes, that might be the best solution. However, there are some email archives and other sources, probably someone could find the answer someday. – Andrey Mar 16 '18 at 21:25

0 Answers0