Record Class VMLauncher
java.lang.Object
java.lang.Record
de.firemage.autograder.core.errorprone.VMLauncher
- Record Components:
jvmArgs- arguments to pass to the new JVM (those are that java -... flags)tempLocation- a location where the result of the code can be written to (used for inter-process communication)
public record VMLauncher(List<String> jvmArgs, TempLocation tempLocation, Optional<String> mainClassName)
extends Record
A class that can be used to run code in a new JVM.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classVMLauncher.VMHandle<T extends Serializable>Represents a reference to the launched VM. -
Constructor Summary
ConstructorsConstructorDescriptionVMLauncher(List<String> jvmArgs, TempLocation tempLocation, Optional<String> mainClassName) Creates an instance of aVMLauncherrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static VMLauncherfromDefault(TempLocation tmpLocation) final inthashCode()Returns a hash code value for this object.jvmArgs()Returns the value of thejvmArgsrecord component.Returns the value of themainClassNamerecord component.<T extends Serializable>
VMLauncher.VMHandle<T>runInNewJVM(SerializableSupplier<T> supplier) Runs the given lambda in a new JVM.Returns the value of thetempLocationrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
VMLauncher
Creates an instance of aVMLauncherrecord class.- Parameters:
jvmArgs- the value for thejvmArgsrecord componenttempLocation- the value for thetempLocationrecord componentmainClassName- the value for themainClassNamerecord component
-
-
Method Details
-
fromDefault
- Throws:
IOException
-
runInNewJVM
public <T extends Serializable> VMLauncher.VMHandle<T> runInNewJVM(SerializableSupplier<T> supplier) throws IOException Runs the given lambda in a new JVM.Note that the IDEs debugger will most likely not attach to code called in this lambda. Therefore, it is recommended to run as little code as possible in this lambda.
- Type Parameters:
T- the type of the result returned by the lambda- Parameters:
supplier- the code to run in the new JVM- Returns:
- a handle to the launched code
- Throws:
IOException- if it failed to serialize the lambda
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
jvmArgs
Returns the value of thejvmArgsrecord component.- Returns:
- the value of the
jvmArgsrecord component
-
tempLocation
Returns the value of thetempLocationrecord component.- Returns:
- the value of the
tempLocationrecord component
-
mainClassName
Returns the value of themainClassNamerecord component.- Returns:
- the value of the
mainClassNamerecord component
-