Skip to main content

ConfigurationBuilder

Struct ConfigurationBuilder 

Source
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

Source

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
Source

pub fn class_path(self, class_path: ClassPath) -> Self

Set the VM class path

Source

pub fn main_class<S: AsRef<str>>(self, main_class: S) -> Self

Set the main class to run

Source

pub fn jar(self, jar: PathBuf) -> Self

Set the jar

Source

pub fn java_home(self, java_home: PathBuf) -> Self

Set the Java home path

Source

pub fn java_version<S: AsRef<str>>(self, version: S) -> Self

Set the Java version

Source

pub fn add_system_property<K, V>(self, key: K, value: V) -> Self
where K: AsRef<str>, V: AsRef<str>,

Add a system property

Source

pub fn system_properties(self, properties: AHashMap<String, String>) -> Self

Set all system properties

Source

pub fn interpreted(self, interpreted: bool) -> Self

Configure the VM to run in interpreted mode

Source

pub fn batch_compilation(self, batch_compilation: bool) -> Self

Configure the VM to use background batch compilation

Source

pub fn preview_features(self) -> Self

Enable preview features

Source

pub fn verify_mode(self, verify_mode: VerifyMode) -> Self

Set the class verification mode

Source

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.

Source

pub fn module_path(self, paths: Vec<PathBuf>) -> Self

Set the module path (-p or –module-path)

Source

pub fn add_module_path(self, path: impl Into<PathBuf>) -> Self

Add a path to the module path

Source

pub fn upgrade_module_path(self, paths: Vec<PathBuf>) -> Self

Set the upgrade module path (–upgrade-module-path)

Source

pub fn add_upgrade_module_path(self, path: impl Into<PathBuf>) -> Self

Add a path to the upgrade module path

Source

pub fn main_module(self, main_module: MainModule) -> Self

Set the main module (–module or -m)

Source

pub fn set_add_modules(self, modules: Vec<String>) -> Self

Set the additional modules to add (–add-modules)

Source

pub fn add_module(self, module: impl Into<String>) -> Self

Add a module to the additional modules list (–add-modules)

Source

pub fn set_limit_modules(self, modules: AHashSet<String>) -> Self

Set the modules to limit observability (–limit-modules)

Source

pub fn limit_module(self, module: impl Into<String>) -> Self

Add a module to the limit modules set (–limit-modules)

Source

pub fn set_add_reads(self, reads: Vec<ModuleRead>) -> Self

Set the read edges to add (–add-reads)

Source

pub fn add_read(self, read: ModuleRead) -> Self

Add a read edge (–add-reads)

Source

pub fn set_add_exports(self, exports: Vec<ModuleExport>) -> Self

Set the exports to add (–add-exports)

Source

pub fn add_export(self, export: ModuleExport) -> Self

Add an export (–add-exports)

Source

pub fn set_add_opens(self, opens: Vec<ModuleOpens>) -> Self

Set the opens to add (–add-opens)

Source

pub fn add_opens(self, opens: ModuleOpens) -> Self

Add an opens directive (–add-opens)

Source

pub fn set_patch_modules(self, patches: Vec<ModulePatch>) -> Self

Set the patch modules (–patch-module)

Source

pub fn add_patch(self, patch: ModulePatch) -> Self

Add a patch module (–patch-module)

Source

pub fn stdin(self, stdin: Arc<Mutex<dyn Read + Send + Sync>>) -> Self

Set the standard input stream

Source

pub fn stdout(self, stdout: Arc<Mutex<dyn Write + Send + Sync>>) -> Self

Set the standard output stream

Source

pub fn stderr(self, stderr: Arc<Mutex<dyn Write + Send + Sync>>) -> Self

Set the standard error stream

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConfigurationBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more