staktrace / cafebabe

A java class file parser
43 stars 12 forks source link

cafebabe

Build Status Crate

cafebabe is a parser for .class files, which are generated by the javac compiler and other compilers targeting the JVM. It supports the class file format from Java 21 (September 2023).

There are a bunch of different class file parsers available on crates.io. Main differentiators for cafebabe are:

Current status

The main parsing code is fully implemented. All structures (including attributes) described in Chapter 4 of the JVM spec are supported. The entire modules file of the OpenJDK 16/17/21 distributions can be parsed without errors. cafebabe will do some kinds of validation/checking at parse time, but not everything described in Chapter 4 of the JVM spec. It does all of section 4.8 validation ("Format checking") except possibly some of the attribute validations (the Signature attribute, for instance). A reasonable goal for this project is to fully implement section 4.8, so patches would be accepted for additional format checking.

Q&A

Why is the project called cafebabe?

Because the first 4 bytes in any valid class file are a magic identifier with the value 0xCAFEBABE. ☕