xref: /netbsd-src/external/bsd/file/dist/magic/magdir/java (revision e15daa8be9575f7ad2ca804c7c7c2d7f8e182d98)
15ccaa8c0Schristos
21b108b8bSchristos#------------------------------------------------------------
3*e15daa8bSchristos# $File: java,v 1.22 2023/01/11 23:59:49 christos Exp $
41b108b8bSchristos# Java ByteCode and Mach-O binaries (e.g., Mac OS X) use the
51b108b8bSchristos# same magic number, 0xcafebabe, so they are both handled
61b108b8bSchristos# in the entry called "cafebabe".
71b108b8bSchristos#------------------------------------------------------------
81b108b8bSchristos# Java serialization
91b108b8bSchristos# From Martin Pool (m.pool@pharos.com.au)
101b108b8bSchristos0	beshort		0xaced		Java serialization data
111b108b8bSchristos>2	beshort		>0x0004		\b, version %d
121b108b8bSchristos
131b108b8bSchristos0	belong		0xfeedfeed	Java KeyStore
141b108b8bSchristos!:mime	application/x-java-keystore
151b108b8bSchristos0	belong		0xcececece	Java JCE KeyStore
161b108b8bSchristos!:mime	application/x-java-jce-keystore
171b108b8bSchristos
18f50962bcSchristos# Java source
19ae9cfef6Schristos0	regex	\^import.*;$	Java source
20f50962bcSchristos!:mime	text/x-java
21ae9cfef6Schristos
22ae9cfef6Schristos# Java HPROF dumps
23ae9cfef6Schristos# https://java.net/downloads/heap-snapshot/hprof-binary-format.html
24ae9cfef6Schristos0	string		JAVA\x20PROFILE\x201.0.
25006f8008Schristos>0x12	byte		0
26006f8008Schristos>>0x11	ubyte-0x31	<2      Java HPROF dump,
27006f8008Schristos>>>0x17	beqdate/1000	x       created %s
28dc958920Schristos
29dc958920Schristos# Java jmod module
30dc958920Schristos# See https://hg.openjdk.java.net/jdk9/jdk9/jdk/file/tip/src/java.base/share/classes/jdk/internal/jmod/JmodFile.java
31dc958920Schristos# Grr. 2 byte magic "JM", really? In 2019?
32dc958920Schristos0	belong		0x4a4d0100	Java jmod module version 1.0
33dc958920Schristos!:mime	application/x-java-jmod
34dc958920Schristos
35dc958920Schristos# Java jlinked image
36dc958920Schristos# See https://hg.openjdk.java.net/jdk9/jdk9/jdk/file/tip/src/java.base/share/native/libjimage/imageFile.hpp
37dc958920Schristos0	belong	0xcafedada	Java module image (big endian)
38dc958920Schristos>4	beshort	>0x00	\b, version %d
39dc958920Schristos>6	beshort	x	\b.%d
40dc958920Schristos!:mime	application/x-java-image
41dc958920Schristos
42dc958920Schristos0	lelong	0xcafedada	Java module image (little endian)
43dc958920Schristos>6	leshort	>0x00	\b, version %d
44dc958920Schristos>4	leshort	x	\b.%d
45dc958920Schristos!:mime	application/x-java-image
46*e15daa8bSchristos
47*e15daa8bSchristos# JAR Manifest & Signature File
48*e15daa8bSchristos# Reference: https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html
49*e15daa8bSchristos0	string/t	Manifest-Version:\x201.0	JAR Manifest
50*e15daa8bSchristos!:ext	MF
51*e15daa8bSchristos0	string/t	Signature-Version:\x201.0	JAR Signature File
52*e15daa8bSchristos!:ext	SF
53