1226048Sobrien 2169942Sobrien#------------------------------------------------------------------------------ 3284778Sdelphij# $File: cafebabe,v 1.20 2015/05/29 14:21:58 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) 31284778Sdelphij>>4 belong 0x0033 (Java 1.7) 32284778Sdelphij>>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 50277592Sdelphij>(8.L) indirect \b: 51267843Sdelphij>0 belong x \b] 52267843Sdelphij 53191736Sobrien0 belong 0xcafebabe 54267843Sdelphij>4 belong 1 Mach-O universal binary with 1 architecture: 55284778Sdelphij!: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: 59284778Sdelphij!:mime application/x-mach-binary 60267843Sdelphij>>>8 use mach-o \b 61267843Sdelphij>>>28 use mach-o \b 62284778Sdelphij>>4 belong 2 63267843Sdelphij>>>48 use mach-o \b 64284778Sdelphij>>4 belong 3 65267843Sdelphij>>>68 use mach-o \b 66284778Sdelphij>>4 belong 4 67284778Sdelphij>>>88 use mach-o \b 68191736Sobrien 69267843Sdelphij### MACH-O END ### 70