Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are the first four bytes of the Java class file format CAFEBABE?

Tags:

java

Why are the first four bytes of the Java class file format CAFEBABE? Who named it?

Your views/guesses?

Source: IBM Java Programing Dynamics

like image 398
zengr Avatar asked May 11 '10 07:05

zengr


People also ask

What is the significance of Cafebabe in .class file?

At that time, it didn't seem terribly important or destined to go anywhere but the trash can of history. So CAFEBABE became the class file format, and CAFEDEAD was the persistent object format. But the persistent object facility went away, and along with it went the use of CAFEDEAD – it was eventually replaced by RMI.

What is the value in hex of the first four bytes of every Java class file?

lang. java newsgroup. Subject: Why CAFEBABE? The first 4 bytes of every Java class file has the magic value 0xCAFEBABE.

What is Cafebabe?

CAFEBABE is a magic word for a class file.it is consisting of only hex letters. if the class file doesn't have this magic word then it is not a valid class file. 0. By: [email protected] On: Mon Jul 21 15:10:09 IST 2014 0 392 0.

What is the class file format in Java explain in detail?

A Java class file is a file containing Java bytecode and having . class extension that can be executed by JVM. A Java class file is created by a Java compiler from .


1 Answers

James Gosling, the father of Java programming language, once explained it as follows:

As far as I know, I'm the guilty party on this one. I was totally unaware of the NeXT connection. The small number of interesting HEX words is probably the source of the match. As for the derivation of the use of CAFEBABE in Java, it's somewhat circuitous:

We used to go to lunch at a place called St Michael's Alley. According to local legend, in the deep dark past, the Grateful Dead used to perform there before they made it big. It was a pretty funky place that was definitely a Grateful Dead Kinda Place. When Jerry died, they even put up a little Buddhist-esque shrine. When we used to go there, we referred to the place as Cafe Dead.

Somewhere along the line it was noticed that this was a HEX number. I was re-vamping some file format code and needed a couple of magic numbers: one for the persistent object file, and one for classes. I used CAFEDEAD for the object file format, and in grepping for 4 character hex words that fit after CAFE (it seemed to be a good theme) I hit on BABE and decided to use it.

At that time, it didn't seem terribly important or destined to go anywhere but the trash-can of history. So CAFEBABE became the class file format, and CAFEDEAD was the persistent object format. But the persistent object facility went away, and along with it went the use of CAFEDEAD - it was eventually replaced by RMI.

Source:

  • Wikipedia/Class (file format)
  • Bill Bumgarner blog entry: 0xCAFEBABE & 0xFEEDFACE

Somewhat related links

  • Hex words and upside down words
like image 131
polygenelubricants Avatar answered Sep 23 '22 05:09

polygenelubricants