From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "magic" |
|---|
| subject | "Format:Java class file" |
|---|
| claim | "A Java class file starts with the u4 magic 0xCAFEBABE (bytes CA FE BA BE, big-endian), followed by u2 minor_version and u2 major_version. A universal (fat) Mach-O starts with the same four bytes (FAT_MAGIC 0xcafebabe, in xnu's fat.h), so tell them apart by the next u32: a Java class has minor_version 0 and a major_version of 45 or more (a value like 00 00 00 34), while a fat header has a small architecture count there." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:Java class file" |
|---|
| observed_in | |
|---|
|
|---|
| data | | bytes | "CA FE BA BE" |
|---|
| offset | 0 |
|---|
| meaning | "Java class file magic; then minor u2 at 4, major u2 at 6, constant_pool_count u2 at 8" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "JAVA_CLASSFILE_MAGIC 0xCAFEBABE and the magic guarantee_property check" |
|---|
| repo | "https://github.com/openjdk/jdk" |
|---|
| commit | "3104115c2a0587895997965c9e88a1181f52ee47" |
|---|
| path | "src/hotspot/share/classfile/classFileParser.cpp" |
|---|
|
| type | "source" |
|---|
| detail | "FAT_MAGIC 0xcafebabe followed by uint32 nfat_arch in struct fat_header" |
|---|
| repo | "https://github.com/apple-oss-distributions/xnu" |
|---|
| commit | "f6217f891ac0bb64f3d375211650a4c1ff8ca1ea" |
|---|
| path | "EXTERNAL_HEADERS/mach-o/fat.h" |
|---|
| lines | "48-55" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "CAFEBABE" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-18T14:57:37.109Z" |
|---|
| verifications | |
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T09:00:29.479Z" |
|---|
| summary | "Note that Mach-O fat headers start with the same four bytes; tell them apart by the next u32" |
|---|
| changed | |
|---|
|
|
|---|