Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Java serialisation why does J signify a long and L signify an Object?

When you serialise an object in Java, the letter J is used to signify the next bytes represent a long and the letter L is used to signify that an Object is next, but why? Why not use O for Object and L for long?

like image 887
mjaggard Avatar asked Feb 14 '13 19:02

mjaggard


1 Answers

These letters certainly were choosen because of conflicts. A guesswork of that conflicts:

  • C was taken for char. So, they used L for class.

  • L was taken for class. So, they used J for long.

  • B was taken for byte. So, they used Z for boolean.

By the way, 'L' doesn't mean 'Object', but 'fully-qualified-class'.

like image 87
Italo Borssatto Avatar answered Oct 20 '22 03:10

Italo Borssatto