3 releases (breaking)

0.7.0 Aug 20, 2024
0.6.0 Aug 15, 2024
0.5.0 Aug 9, 2024

#656 in Development tools

Download history 95/week @ 2024-08-04 105/week @ 2024-08-11 155/week @ 2024-08-18 6/week @ 2024-08-25

361 downloads per month

Apache-2.0 OR MIT

625KB
15K SLoC

Ristretto ClassLoader

ci Documentation Code Coverage Benchmarks Latest version License Semantic Versioning

Getting Started

Implementation of a JVM Class Loader that is used to load Java classes. Classes can be loaded from the file system or from a URL; jar and modules are supported. A runtime Java class loader can be created from any version of AWS Corretto. The runtime class loader will download and install the requested version of Corretto into and create a class loader that can be used to load Java classes.

The AWS Corretto runtime is installed in the following directory:

  • Unix: $HOME/.ristretto/<version>
  • Windows: %USERPROFILE%\.ristretto\<version>

Examples

use ristretto_classloader::{ClassLoader, ClassPath, Result};
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<()> {
    #[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(())
    }
}

Feature flags

The following features are available:

Name Description Default?
url Enables url class path entries No

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

~9–22MB
~366K SLoC