Модераторы: LSD, AntonSaburov
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Почему 0xCAFEBABE, ;-) 
:(
    Опции темы
Domestic Cat
Дата 29.5.2005, 05:26 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Экс. модератор
Сообщений: 5452
Регистрация: 3.5.2004
Где: Dallas, US

Репутация: 50
Всего: 172



Вот наткнулся smile Показалось весьма забавным smile

-------------------------------------------------------------------------------------------------------------------

Subject: Why CAFEBABE?
Date: Mon, 20 May 1996
From: Bill Venners <[email protected]>
To: comp.lang.java
The first 4 bytes of every Java class file has the magic value 0xCAFEBABE. I am curious. Does anyone know how this value was chosen? Does anyone who doesn't know want to venture a guess?

Thanks in advance.

bv

--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Mon, 20 May 1996 19:53:33 -0500
From: Matthew Travis <[email protected]>
To: comp.lang.java
I have heard why before, but the answer seems to have long since been deleted from my e-mail archives. I, too, would like to know why. why?

matt


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Wed, 22 May 1996 12:16:27 +0100
From: Rolf Howarth <[email protected]>
To: comp.lang.java
Bill Venners wrote:

The first 4 bytes of every Java class file has the magic value 0xCAFEBABE. I am curious. Does anyone know how this value was chosen? Does anyone who doesn't know want to venture a guess?

Well, they presumably had to pick something as their magic number to identify class files, and there's a limit to how many Java or coffee related words you can come up with using just the letters A-F :-)

-Rolf


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Tue, 21 May 1996 12:31:36 -0600
From: Alastair Mayer <[email protected]>
To: comp.lang.java
Matthew Travis wrote:

I have heard why before, but the answer seems to have long since been deleted from my e-mail archives. I, too, would like to know why. why?

matt

Well, the file has to start with *some* magic number (or string) to make it easy to recognize as a valid class file and not something else.

As to why the magic number is 3405691582 (0xCAFEBABE), well my guess is that (a) 32-bit magic numbers are easier to handle and more likely to be unique, and (b) the Java team wanted something with the Java-coffee metaphor, and since there's no 'J' or 'V' in hexadecimal, settled for something with CAFE in it. I guess they figured "CAFE BABE" was sexier than something like "A FAB CAFE" or "CAFE FACE", and definitely didn't like the implications of "CAFE A FAD" (or worse, "A BAD CAFE").

:-)

-- Alastair

(BTW, of course they're far from the first to use hex digits to spell out meaningful words in their magic numbers. Twenty-something years ago the Burroughs B6700 initialized its "uninitialized" memory of 48-bit words to 0xBADBADBADBAD.)


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Wed, 22 May 1996 11:04:39 -0600
From: Alastair Mayer <[email protected]>
To: comp.lang.java
Alastair Mayer wrote:

[snip]

it. I guess they figured "CAFE BABE" was sexier than something like "A FAB CAFE" or "CAFE FACE", and definitely didn't like the implications of "CAFE A FAD" (or worse, "A BAD CAFE").

:-)

Don't know why I missed this before, but they *could* have used the number 12648430, if you choose to read the hex zeros as the letter 'O'. That gives you 0xC0FFEE, or 0x00C0FFEE to specify all 32 bits. OO COFFEE? Object Oriented, of course... :-)

-- Alastair


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Wed, 22 May 1996 19:43:46 GMT
From: David N. Smith <[email protected]>
To: comp.lang.java

Alastair Mayer wrote:

Well, the file has to start with *some* magic number (or string)to make it easy to recognize as a valid class file and not something else.

As to why the magic number is 3405691582 (0xCAFEBABE), well my guess is that (a) 32-bit magic numbers are easier to handle and more likely to be unique, and (b) the Java team wanted something with the Java-coffee metaphor, and since there's no 'J' or 'V' in hexadecimal, settled for something with CAFE in it. I guess they figured "CAFE BABE" was sexier than something like "A FAB CAFE" or "CAFE FACE", and definitely didn't like the implications of "CAFE A FAD" (or worse, "A BAD CAFE").

:-)

-- Alastair

(BTW, of course they're far from the first to use hex digits to spell out meaningful words in their magic numbers. Twenty-something years ago the Burroughs B6700 initialized its "uninitialized" memory of 48-bit words to 0xBADBADBADBAD.)

Back when I was a mere child, I was helping a numerical analyst debug a program. The S/360 core dump (anyone remember hex matrixes!) finally yielded up the culpret: a very out-of-range floating point value.

The first three digits were 0xBAD.

I had a hell of a time convincing that guy that it was purely a coincidence!

Dave


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Sun, 26 May 1996 02:40:10 -0700
From: Paul Snively <[email protected]>
To: comp.lang.java
David N. Smith wrote:

Back when I was a mere child, I was helping a numerical analyst debug a program. The S/360 core dump (anyone remember hex matrixes!) finally yielded up the culpret: a very out-of-range floating point value.

The first three digits were 0xBAD.

I had a hell of a time convincing that guy that it was purely a coincidence!

A canonical (that is, referred to explicitly in "The New Hacker's Dictionary") "bogus value" to stick in places that need an easily-identifiable bogus value is 0xDEADBEEF.

On the Macintosh, which lacks protected memory, a popular thing to do is to stick some magic number into location 0 so that dereferencing a null pointer or handle will crash immediately. Long ago, a friend used the ASCII value of 'NIL!' for the purpose, but time and some real thought about what a good value on the Macintosh really was eventually led to 0x50FFC001, which is a flawless Mac crasher value (for at least three reasons that are left as an exercise to the reader) but unfortunately isn't a cool legible value. --


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: 23 May 1996 04:54:44 GMT
From: Vivian Man Cheng <[email protected]>
To: comp.lang.java
I originally saw 0xCAFEBABE as a magic number used by NeXTSTEP. NX used "fat binaries", which were basically binaries for different platforms stuck together in one executable file. If you were running on NX Intel, it would run the Intel binary; if on HP, it would run the HP binary. 0xCAFEBABE was the magic number to distinguish either the Intel or the Motorola binaries ( can't remember which ).

Seems that Sun carried it over ...


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Sat, 25 May 1996 02:15:20 GMT
From: David Harvey-George <[email protected]>
To: comp.lang.java
Vivian Man Cheng wrote:

I originally saw 0xCAFEBABE as a magic number used by NeXTSTEP.

Strange but true... 0xfeedface is for moto and 0xcafebabe for intel. What about Sun and HP though?

Do you think it's copyrighted or trademarked to NeXT? :-)

David


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Wed May 22 09:17:37 1996
From: James Lynn <[email protected]>

Since the word babe is pretty synonmous with chick, I doubt you'll find any _deep_ meaning here. When I hear "CafeBabe" I think of a typical Coffee Grrl: nose peirced, minimum one tatoo, hair dyed black, hate the world the government and parents, and is rather attractive in a necro sort of way.

But that's what I get from it. It could be a tribute to the waitress who served Sun's Java team at their favorite bean hole. Or, maybe it one of the few things they could spell with A-F, and CAFEBEEF or DEADCAFE wasn't nearly as nice sounding to them as CAFEBABE.

Who knows. You could write them.


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Fri, 24 May 1996 16:35:55 GMT
From: Lee Crocker <[email protected]>
To: comp.lang.java
(BTW, of course they're far from the first to use hex digits to spell out meaningful words in their magic numbers. Twenty-something years ago the Burroughs B6700 initialized its "uninitialized" memory of 48-bit words to 0xBADBADBADBAD.)

And don't forget the old IBM machines that used 0xDEADBEEF for the same purpose. Using uninitialized memory is still called a "dead beef error" in some circles (at least among programmers old enough to remember that).


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Tue, 28 May 96 16:20:57 GMT
From: William Halchin <[email protected]>
To: comp.lang.java
Lee Crocker wrote:

(BTW, of course they're far from the first to use hex digits to spell out meaningful words in their magic numbers. Twenty-something years ago the Burroughs B6700 initialized its "uninitialized" memory of 48-bit words to 0xBADBADBADBAD.)

And don't forget the old IBM machines that used 0xDEADBEEF for the same purpose. Using uninitialized memory is still called a "dead beef error" in some circles (at least among programmers old enough to remember that).

AIX on RS6000 still uses 0xdeadbeaf to represent unitialized storage.

Vasili N. Galchin


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Sun, 26 May 1996 22:12:58 -0700
From: Patrick Naughton <[email protected]>
To: comp.lang.java
Bill Venners wrote:

The first 4 bytes of every Java class file has the magic value 0xCAFEBABE. I am curious. Does anyone know how this value was chosen? Does anyone who doesn't know want to venture a guess?

Strangely enough the magic number for .class files was chosen long before the name Java was ever uttered in reference to this language. We were looking for something fun, unique and easy to remember. 0xcafebabe was better than the second runner-up, 0xdeadbabe. :-)

It is only a coincidence that the oblique reference to the cute barristas at Peet's Coffee was foreshadowing for the name Java.


--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
From: Simon Bennett <[email protected]>
To: comp.lang.java
Patrick Naughton wrote:

Strangely enough the magic number for .class files was chosen long before the name Java was ever uttered in reference to this language. We were looking for something fun, unique and easy to remember. 0xcafebabe was better than the second runner-up, 0xdeadbabe. :-)

0xdeadbabe is used at the start of all IRIX arena files! So good thing you didn't use it! ;)



--------------------------------------------------------------------------------

Subject: Re: Why CAFEBABE?
Date: Sun, 09 Jun 1996 19:25:32 GMT
From: Bob Pasker <[email protected]>
To: comp.lang.java

Simon Bennett wrote:

0xdeadbabe is used at the start of all IRIX arena files! So good thing you didn't use it! ;)

and a debugging solaris kernel puts 0xCAFEFEED into all kmemfree() blocks. --b


--------------------

PM   Вверх
batigoal
Дата 29.5.2005, 09:14 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Нелетучий Мыш
****


Профиль
Группа: Участник Клуба
Сообщений: 6423
Регистрация: 28.12.2004
Где: Санктъ-Петербургъ

Репутация: 24
Всего: 151



Цитата(Domestic @ 29.5.2005, 06:26)
When I hear "CafeBabe" I think of a typical Coffee Grrl: nose peirced, minimum one tatoo, hair dyed black, hate the world the government and parents, and is rather attractive in a necro sort of way.

smile

А для чего вообще нужны эти magic number'ы?


--------------------
"Чтобы правильно задать вопрос, нужно знать большую часть ответа" (Р. Шекли)
ЖоржЖЖ
PM WWW   Вверх
Domestic Cat
Дата 29.5.2005, 09:18 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Экс. модератор
Сообщений: 5452
Регистрация: 3.5.2004
Где: Dallas, US

Репутация: 50
Всего: 172



Цитата(Lamer @ 29.5.2005, 00:14)

А для чего вообще нужны эти magic number'ы?

Чтобы идентифицировать файл как класс.


--------------------

PM   Вверх
batigoal
Дата 29.5.2005, 09:59 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Нелетучий Мыш
****


Профиль
Группа: Участник Клуба
Сообщений: 6423
Регистрация: 28.12.2004
Где: Санктъ-Петербургъ

Репутация: 24
Всего: 151



Помню, был у меня такой баг: если IDEA зависала при компиляции, то потом отказывалась компилировать, мотивируя это bad magic number'ом. Лечилось ручным удалением class-файлов. Теперь понятно, в чем дело было.


--------------------
"Чтобы правильно задать вопрос, нужно знать большую часть ответа" (Р. Шекли)
ЖоржЖЖ
PM WWW   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Java"
LSD   AntonSaburov
powerOn   tux
javastic
  • Прежде, чем задать вопрос, прочтите это!
  • Книги по Java собираются здесь.
  • Документация и ресурсы по Java находятся здесь.
  • Используйте теги [code=java][/code] для подсветки кода. Используйтe чекбокс "транслит", если у Вас нет русских шрифтов.
  • Помечайте свой вопрос как решённый, если на него получен ответ. Ссылка "Пометить как решённый" находится над первым постом.
  • Действия модераторов можно обсудить здесь.
  • FAQ раздела лежит здесь.

Если Вам помогли, и атмосфера форума Вам понравилась, то заходите к нам чаще! С уважением, LSD, AntonSaburov, powerOn, tux, javastic.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Java: Общие вопросы | Следующая тема »


 




[ Время генерации скрипта: 0.0458 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.