Crate ristretto_classloader

Crate ristretto_classloader 

Source
Expand description

§Ristretto ClassLoader

Code Coverage Benchmarks 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 a LTS version of AWS Corretto. The runtime class loader will download and install the requested version of Corretto 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::{runtime, ClassLoader, Result};
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<()> {
    let (_java_home, java_version, class_loader) = runtime::version_class_loader("21").await?;
    let class_name = "java.util.HashMap";
    println!("Loading {class_name} from Java version {java_version}");
    let class = class_loader.load(class_name).await?;
    println!("{class:?}");
    Ok(())
}

§Feature flags

The following features are available:

NameDescriptionDefault?
urlEnables url class path entriesNo

§Safety

This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.

Re-exports§

pub use runtime::DEFAULT_JAVA_VERSION;

Modules§

manifest
runtime

Structs§

Class
A representation of a Java class.
ClassLoader
Implementation of a Java class loader.
ClassPath
Represents a class path.
Field
FieldAccessFlags
Field access flags used in Java class files to specify the access permissions and properties of fields.
Manifest
Represents a Jar manifest. See: https://docs.oracle.com/en/java/javase/22/docs/specs/jar/jar.html#jar-manifest
Method
MethodAccessFlags
Method access flags used in Java class files to specify the access permissions and properties of methods.
Object
Represents an object in the Ristretto VM.
ObjectArray
Represents an array of objects in the Ristretto VM.

Enums§

BaseType
Represents the primitive types in the Java Virtual Machine.
ClassPathEntry
Represents a class path entry.
Error
Errors that can occur when loading classes
FieldType
Represents a Java field type descriptor as defined in the JVM specification.
Reference
Represents a reference to an object in the Ristretto VM.
Value
Represents a value in the Ristretto VM.

Type Aliases§

Result
Ristretto classloader result type