为什么Java类文件格式的前四个字节是CAFEBABE? [英] Why are the first four bytes of the Java class file format CAFEBABE?

查看:389
本文介绍了为什么Java类文件格式的前四个字节是CAFEBABE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

您的观点/猜测?

来源: IBM Java编程动态

推荐答案

Java编程语言之父James Gosling曾解释如下:

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


目前为止据我所知,我是这个人的罪魁祸首。我完全没有意识到NeXT的连接。少量有趣的HEX词可能是比赛的来源。至于在Java中推导使用 CAFEBABE ,它有点迂回:

我们曾经去过午餐在一个叫做圣迈克尔小巷的地方。根据当地的传说,在深黑的过去,感恩的死者曾经在他们做大之前在那里表演。这是一个非常时髦的地方,绝对是一个感恩的死亡金点。当杰瑞去世时,他们甚至还建了一座佛教圣地。当我们去那里的时候,我们把这个地方称为Cafe Dead。

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.

在某个地方,人们注意到这是一个十六进制数字。我正在重新编写一些文件格式代码,需要一些神奇的数字:一个用于持久对象文件,一个用于类。我使用 CAFEDEAD 作为目标文件格式,并使用 CAFE 之后的4个字符十六进制单词的grepping(似乎成为一个好主题)我点击 BABE 并决定使用它。

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.

当时,它没有看起来非常重要或注定要去除历史的垃圾桶。所以 CAFEBABE 成为类文件格式, CAFEDEAD 是持久对象格式。但持久对象工具消失了,随之而来的是使用 CAFEDEAD - 它最终被RMI取代。

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.



资料来源:



查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆