gpt4 book ai didi

java - 为什么Java类文件格式的前四个字节是CAFEBABE?

转载 作者:IT老高 更新时间:2023-10-28 20:44:54 26 4
gpt4 key购买 nike

为什么Java类文件格式的前四个字节是CAFEBABE?谁给它起名?

你的观点/猜测?

来源:IBM Java Programing Dynamics

最佳答案

Java 编程语言之父詹姆斯·高斯林曾这样解释:

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.

来源:

有些相关的链接

关于java - 为什么Java类文件格式的前四个字节是CAFEBABE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2808646/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com