#java #jvm #java-class #bytecode #classfile #read-write

ristretto_classfile

A library for reading, writing and verifying Java classfiles

9 releases (breaking)

0.7.0 Aug 20, 2024
0.6.0 Aug 15, 2024
0.5.0 Aug 9, 2024
0.4.0 Jul 26, 2024
0.1.0 Jul 9, 2024

#654 in Development tools

Download history 203/week @ 2024-07-05 211/week @ 2024-07-12 139/week @ 2024-07-19 197/week @ 2024-07-26 12/week @ 2024-08-02 174/week @ 2024-08-09 187/week @ 2024-08-16 17/week @ 2024-08-23

396 downloads per month
Used in ristretto_classloader

Apache-2.0 OR MIT

550KB
13K SLoC

Ristretto ClassFile

ci Documentation Code Coverage Benchmarks Latest version License Semantic Versioning

Getting Started

Implementation of the JVM Class File Format that is used to read, write and verify Java classes.

Supports reading and writing class files for any version of Java version up to 24. Verification of class files is supported, but is still a work in progress.

Examples

use ristretto_classfile::{ClassFile, ConstantPool, Result, Version};

fn main() -> Result<()> {
    let mut constant_pool = ConstantPool::default();
    let this_class = constant_pool.add_class("Foo")?;
    let class_file = ClassFile {
        version: Version::Java21 { minor: 0 },
        constant_pool,
        this_class,
        ..Default::default()
    };
    class_file.verify()
}

Safety

These crates use #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

VSCode Development Container
GitHub Codespaces

Dependencies

~0.4–1MB
~21K SLoC