pub struct ConfigurationBuilder { /* private fields */ }Expand description
Builder for creating a Configuration with a fluent interface.
This builder provides methods to set all the configuration options
and then create a Configuration instance with the build() method.
§Example
use ristretto_vm::ConfigurationBuilder;
use ristretto_classloader::ClassPath;
let config = ConfigurationBuilder::new()
.class_path(ClassPath::from(&["."]))
.main_class("com.example.Main")
.java_version("21")
.build()
.unwrap();Implementations§
Source§impl ConfigurationBuilder
impl ConfigurationBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ConfigurationBuilder with default values.
Default values include:
- No class path (will be set to “.” when building)
- No main class
- No JAR file
- No Java home
- Default Java version (will be set when building if no Java home is provided)
- Empty system properties
- JIT mode enabled
- Background batch compilation enabled
- Preview features disabled
- Verify mode set to Remote (verify only remote/untrusted classes)
- Standard output and error streams directed to system stdout/stderr
Sourcepub fn class_path(self, class_path: ClassPath) -> Self
pub fn class_path(self, class_path: ClassPath) -> Self
Set the VM class path
Sourcepub fn main_class<S: AsRef<str>>(self, main_class: S) -> Self
pub fn main_class<S: AsRef<str>>(self, main_class: S) -> Self
Set the main class to run
Sourcepub fn java_version<S: AsRef<str>>(self, version: S) -> Self
pub fn java_version<S: AsRef<str>>(self, version: S) -> Self
Set the Java version
Sourcepub fn add_system_property<K, V>(self, key: K, value: V) -> Self
pub fn add_system_property<K, V>(self, key: K, value: V) -> Self
Add a system property
Sourcepub fn system_properties(self, properties: AHashMap<String, String>) -> Self
pub fn system_properties(self, properties: AHashMap<String, String>) -> Self
Set all system properties
Sourcepub fn interpreted(self, interpreted: bool) -> Self
pub fn interpreted(self, interpreted: bool) -> Self
Configure the VM to run in interpreted mode
Sourcepub fn batch_compilation(self, batch_compilation: bool) -> Self
pub fn batch_compilation(self, batch_compilation: bool) -> Self
Configure the VM to use background batch compilation
Sourcepub fn preview_features(self) -> Self
pub fn preview_features(self) -> Self
Enable preview features
Sourcepub fn verify_mode(self, verify_mode: VerifyMode) -> Self
pub fn verify_mode(self, verify_mode: VerifyMode) -> Self
Set the class verification mode
Sourcepub fn garbage_collector(self, garbage_collector: Arc<GarbageCollector>) -> Self
pub fn garbage_collector(self, garbage_collector: Arc<GarbageCollector>) -> Self
Set the garbage collector
If not set, the VM will create a default garbage collector.
Sourcepub fn module_path(self, paths: Vec<PathBuf>) -> Self
pub fn module_path(self, paths: Vec<PathBuf>) -> Self
Set the module path (-p or –module-path)
Sourcepub fn add_module_path(self, path: impl Into<PathBuf>) -> Self
pub fn add_module_path(self, path: impl Into<PathBuf>) -> Self
Add a path to the module path
Sourcepub fn upgrade_module_path(self, paths: Vec<PathBuf>) -> Self
pub fn upgrade_module_path(self, paths: Vec<PathBuf>) -> Self
Set the upgrade module path (–upgrade-module-path)
Sourcepub fn add_upgrade_module_path(self, path: impl Into<PathBuf>) -> Self
pub fn add_upgrade_module_path(self, path: impl Into<PathBuf>) -> Self
Add a path to the upgrade module path
Sourcepub fn main_module(self, main_module: MainModule) -> Self
pub fn main_module(self, main_module: MainModule) -> Self
Set the main module (–module or -m)
Sourcepub fn set_add_modules(self, modules: Vec<String>) -> Self
pub fn set_add_modules(self, modules: Vec<String>) -> Self
Set the additional modules to add (–add-modules)
Sourcepub fn add_module(self, module: impl Into<String>) -> Self
pub fn add_module(self, module: impl Into<String>) -> Self
Add a module to the additional modules list (–add-modules)
Sourcepub fn set_limit_modules(self, modules: AHashSet<String>) -> Self
pub fn set_limit_modules(self, modules: AHashSet<String>) -> Self
Set the modules to limit observability (–limit-modules)
Sourcepub fn limit_module(self, module: impl Into<String>) -> Self
pub fn limit_module(self, module: impl Into<String>) -> Self
Add a module to the limit modules set (–limit-modules)
Sourcepub fn set_add_reads(self, reads: Vec<ModuleRead>) -> Self
pub fn set_add_reads(self, reads: Vec<ModuleRead>) -> Self
Set the read edges to add (–add-reads)
Sourcepub fn add_read(self, read: ModuleRead) -> Self
pub fn add_read(self, read: ModuleRead) -> Self
Add a read edge (–add-reads)
Sourcepub fn set_add_exports(self, exports: Vec<ModuleExport>) -> Self
pub fn set_add_exports(self, exports: Vec<ModuleExport>) -> Self
Set the exports to add (–add-exports)
Sourcepub fn add_export(self, export: ModuleExport) -> Self
pub fn add_export(self, export: ModuleExport) -> Self
Add an export (–add-exports)
Sourcepub fn set_add_opens(self, opens: Vec<ModuleOpens>) -> Self
pub fn set_add_opens(self, opens: Vec<ModuleOpens>) -> Self
Set the opens to add (–add-opens)
Sourcepub fn add_opens(self, opens: ModuleOpens) -> Self
pub fn add_opens(self, opens: ModuleOpens) -> Self
Add an opens directive (–add-opens)
Sourcepub fn set_patch_modules(self, patches: Vec<ModulePatch>) -> Self
pub fn set_patch_modules(self, patches: Vec<ModulePatch>) -> Self
Set the patch modules (–patch-module)
Sourcepub fn add_patch(self, patch: ModulePatch) -> Self
pub fn add_patch(self, patch: ModulePatch) -> Self
Add a patch module (–patch-module)
Sourcepub fn stdin(self, stdin: Arc<Mutex<dyn Read + Send + Sync>>) -> Self
pub fn stdin(self, stdin: Arc<Mutex<dyn Read + Send + Sync>>) -> Self
Set the standard input stream
Sourcepub fn stdout(self, stdout: Arc<Mutex<dyn Write + Send + Sync>>) -> Self
pub fn stdout(self, stdout: Arc<Mutex<dyn Write + Send + Sync>>) -> Self
Set the standard output stream
Sourcepub fn stderr(self, stderr: Arc<Mutex<dyn Write + Send + Sync>>) -> Self
pub fn stderr(self, stderr: Arc<Mutex<dyn Write + Send + Sync>>) -> Self
Set the standard error stream
Sourcepub fn build(self) -> Result<Configuration>
pub fn build(self) -> Result<Configuration>
Build the configuration
§Errors
An error will be returned if:
- Both Java home and Java version are specified (mutually exclusive)
Trait Implementations§
Source§impl Debug for ConfigurationBuilder
impl Debug for ConfigurationBuilder
Auto Trait Implementations§
impl Freeze for ConfigurationBuilder
impl !RefUnwindSafe for ConfigurationBuilder
impl Send for ConfigurationBuilder
impl Sync for ConfigurationBuilder
impl Unpin for ConfigurationBuilder
impl !UnwindSafe for ConfigurationBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more