Expand description
§Ristretto ClassLoader
§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:
Name | Description | Default? |
---|---|---|
url | Enables url class path entries | No |
§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§
Structs§
- Class
- A representation of a Java class.
- Class
Loader - Implementation of a Java class loader.
- Class
Path - Represents a class path.
- Field
- Field
Access Flags - 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
- Method
Access Flags - 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.
- Object
Array - Represents an array of objects in the Ristretto VM.
Enums§
- Base
Type - Represents the primitive types in the Java Virtual Machine.
- Class
Path Entry - Represents a class path entry.
- Error
- Errors that can occur when loading classes
- Field
Type - 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