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.
  • Constructor Details

    • VMLauncher

      public VMLauncher(List<String> jvmArgs, TempLocation tempLocation, Optional<String> mainClassName)
      Creates an instance of a VMLauncher record class.
      Parameters:
      jvmArgs - the value for the jvmArgs record component
      tempLocation - the value for the tempLocation record component
      mainClassName - the value for the mainClassName record component
  • Method Details

    • fromDefault

      public static VMLauncher fromDefault(TempLocation tmpLocation) throws IOException
      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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • jvmArgs

      public List<String> jvmArgs()
      Returns the value of the jvmArgs record component.
      Returns:
      the value of the jvmArgs record component
    • tempLocation

      public TempLocation tempLocation()
      Returns the value of the tempLocation record component.
      Returns:
      the value of the tempLocation record component
    • mainClassName

      public Optional<String> mainClassName()
      Returns the value of the mainClassName record component.
      Returns:
      the value of the mainClassName record component