1226048Sobrien
2169942Sobrien#------------------------------------------------------------------------------
3298192Sdelphij# $File: cafebabe,v 1.21 2015/10/15 20:56:51 christos Exp $
4169942Sobrien# Cafe Babes unite!
5169942Sobrien#
6267843Sdelphij# Since Java bytecode and Mach-O universal binaries have the same magic number,
7267843Sdelphij# the test must be performed in the same "magic" sequence to get both right.
8267843Sdelphij# The long at offset 4 in a Mach-O universal binary tells the number of
9267843Sdelphij# architectures; the short at offset 4 in a Java bytecode file is the JVM minor
10267843Sdelphij# version and the short at offset 6 is the JVM major version.  Since there are only 
11169942Sobrien# only 18 labeled Mach-O architectures at current, and the first released 
12169942Sobrien# Java class format was version 43.0, we can safely choose any number
13169942Sobrien# between 18 and 39 to test the number of architectures against
14169942Sobrien# (and use as a hack). Let's not use 18, because the Mach-O people
15169942Sobrien# might add another one or two as time goes by...
16169942Sobrien#
17267843Sdelphij### JAVA START ###
18191736Sobrien0	belong		0xcafebabe
19267843Sdelphij>4	belong		>30		compiled Java class data,
20186690Sobrien!:mime	application/x-java-applet
21191736Sobrien>>6	beshort		x	        version %d.
22191736Sobrien>>4	beshort		x       	\b%d
23192348Sdelphij# Which is which?
24192348Sdelphij#>>4	belong		0x032d		(Java 1.0)
25192348Sdelphij#>>4	belong		0x032d		(Java 1.1)
26192348Sdelphij>>4	belong		0x002e		(Java 1.2)
27192348Sdelphij>>4	belong		0x002f		(Java 1.3)
28192348Sdelphij>>4	belong		0x0030		(Java 1.4)
29192348Sdelphij>>4	belong		0x0031		(Java 1.5)
30192348Sdelphij>>4	belong		0x0032		(Java 1.6)
31284237Sdelphij>>4	belong		0x0033		(Java 1.7)
32284237Sdelphij>>4	belong		0x0034		(Java 1.8)
33191736Sobrien
34267843Sdelphij0	belong		0xcafed00d	JAR compressed with pack200,
35267843Sdelphij>5	byte		x		version %d.
36267843Sdelphij>4	byte		x		\b%d
37267843Sdelphij!:mime	application/x-java-pack200
38192348Sdelphij
39267843Sdelphij
40267843Sdelphij0	belong		0xcafed00d	JAR compressed with pack200,
41267843Sdelphij>5	byte		x		version %d.
42267843Sdelphij>4	byte		x		\b%d
43267843Sdelphij!:mime	application/x-java-pack200
44267843Sdelphij
45267843Sdelphij### JAVA END ###
46267843Sdelphij### MACH-O START ###
47267843Sdelphij
48267843Sdelphij0	name		mach-o		\b [
49267843Sdelphij>0	use		mach-o-cpu	\b
50276577Sdelphij>(8.L)	indirect			\b: 
51267843Sdelphij>0	belong		x		\b]
52267843Sdelphij
53191736Sobrien0	belong		0xcafebabe
54267843Sdelphij>4	belong		1		Mach-O universal binary with 1 architecture:
55284237Sdelphij!:mime application/x-mach-binary
56267843Sdelphij>>8	use		mach-o		\b
57191736Sobrien>4	belong		>1
58267843Sdelphij>>4	belong		<20		Mach-O universal binary with %d architectures:
59284237Sdelphij!:mime application/x-mach-binary
60267843Sdelphij>>>8	use		mach-o		\b
61298192Sdelphij>>4	belong		2
62267843Sdelphij>>>28	use		mach-o		\b
63298192Sdelphij>>4	belong		3
64267843Sdelphij>>>48	use		mach-o		\b
65298192Sdelphij>>4	belong		4
66267843Sdelphij>>>68	use		mach-o		\b
67298192Sdelphij>>4	belong		5
68284237Sdelphij>>>88	use		mach-o		\b
69298192Sdelphij>>4	belong		6
70298192Sdelphij>>>108	use		mach-o		\b
71191736Sobrien
72267843Sdelphij### MACH-O END ###
73