cafebabe 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #------------------------------------------------------------------------------
  2. # $File: cafebabe,v 1.8 2009/09/19 16:28:08 christos Exp $
  3. # Cafe Babes unite!
  4. #
  5. # Since Java bytecode and Mach-O fat-files have the same magic number, the test
  6. # must be performed in the same "magic" sequence to get both right. The long
  7. # at offset 4 in a mach-O fat file tells the number of architectures; the short at
  8. # offset 4 in a Java bytecode file is the JVM minor version and the
  9. # short at offset 6 is the JVM major version. Since there are only
  10. # only 18 labeled Mach-O architectures at current, and the first released
  11. # Java class format was version 43.0, we can safely choose any number
  12. # between 18 and 39 to test the number of architectures against
  13. # (and use as a hack). Let's not use 18, because the Mach-O people
  14. # might add another one or two as time goes by...
  15. #
  16. 0 belong 0xcafebabe
  17. !:mime application/x-java-applet
  18. >4 belong >30 compiled Java class data,
  19. >>6 beshort x version %d.
  20. >>4 beshort x \b%d
  21. # Which is which?
  22. #>>4 belong 0x032d (Java 1.0)
  23. #>>4 belong 0x032d (Java 1.1)
  24. >>4 belong 0x002e (Java 1.2)
  25. >>4 belong 0x002f (Java 1.3)
  26. >>4 belong 0x0030 (Java 1.4)
  27. >>4 belong 0x0031 (Java 1.5)
  28. >>4 belong 0x0032 (Java 1.6)
  29. 0 belong 0xcafebabe
  30. >4 belong 1 Mach-O fat file with 1 architecture
  31. >4 belong >1
  32. >>4 belong <20 Mach-O fat file with %ld architectures
  33. 0 belong 0xcafed00d JAR compressed with pack200,
  34. >>5 byte x version %d.
  35. >>4 byte x \b%d
  36. !:mime application/x-java-pack200