Crates for the JVM Specification
Crates for the JVM Specification
- loading classes from any version of AWS Corretto
- load classes from directories, jars, modules
- url classes loading from jars and modules
- reading, writing, verifying classes for any version of Java version up to 24
- verification of class files is supported, but is still a work in progress.
use ristretto_classloader::{runtime, ClassLoader, Result};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<()> {
let (version, class_loader) = runtime::class_loader("21").await?;
let class_name = "java.util.HashMap";
println!("Loading {class_name} from Java runtime {version}");
let class = ClassLoader::load_class(&Arc::new(class_loader), class_name).await?;
println!("{class:?}");
Ok(())
}
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()
}
These crates use #![forbid(unsafe_code)]
to ensure everything is implemented in 100% safe Rust.
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
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.