Skip to content

Commit

Permalink
Tests against openjdk17 and 21
Browse files Browse the repository at this point in the history
  • Loading branch information
xitep authored and staktrace committed Jun 27, 2024
1 parent 5915321 commit 218b95b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ cafebabe
![Build Status](https://github.com/staktrace/cafebabe/actions/workflows/test.yml/badge.svg)
[![Crate](https://img.shields.io/crates/v/cafebabe.svg)](https://crates.io/crates/cafebabe)

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 17 (September 2021).
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:
- *Support for Java 17.*
As of this writing, others generally support Java 8 / Java 11.
- *Support for Java 21.*
- *A better user API*.
Most other parsers expose the raw u16 values of the constant pool, which means you as the user end up being responsible for doing the constant pool lookup.
This also means you have to do type validation (e.g. make sure the constant pool entry you're reading is actually a classinfo type, or whatever).
Expand All @@ -30,8 +29,8 @@ There are a bunch of different class file parsers available on crates.io. Main d

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 distribution can be parsed without errors.
The main parsing code is fully implemented. All structures (including attributes) described in [Chapter 4 of the JVM spec](https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-4.html) 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.
Expand All @@ -40,4 +39,4 @@ 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.
Because the first 4 bytes in any valid class file are a magic identifier with the value 0xCAFEBABE.
Binary file added tests/parse/tgz/openjdk17.0.11-modules.tgz
Binary file not shown.
Binary file added tests/parse/tgz/openjdk21.0.3-modules.tgz
Binary file not shown.

0 comments on commit 218b95b

Please sign in to comment.