Class LazyConstantsSecondPreviewExamples

java.lang.Object
net.jrodolfo.java_evolution.java26.lazy_constants.LazyConstantsSecondPreviewExamples

public class LazyConstantsSecondPreviewExamples extends Object
Demonstrates the second preview of Lazy Constants from JEP 526.

The preview API is exercised in an isolated child JVM. The generated probe verifies deferred initialization, one-time supplier evaluation, stable reuse, and the non-initializing orElse operation without external state.

  • Constructor Details

    • LazyConstantsSecondPreviewExamples

      public LazyConstantsSecondPreviewExamples()
  • Method Details

    • runLazyConstantsWorkflow

      Runs the Java 26 preview Lazy Constants workflow.
      Parameters:
      workspace - temporary directory for generated source and classes
      Returns:
      result containing compilation and execution output
      Throws:
      IOException - when the source file cannot be written
      InterruptedException - when waiting for a child process is interrupted
    • probeSource

      public String probeSource()
      Source used by the child JVM to exercise the preview Lazy Constants API.
      Returns:
      generated Java source
    • problem

      public String problem()
      Explains the problem addressed by Lazy Constants.
      Returns:
      a short problem statement
    • comparisonWithFinalFields

      public String comparisonWithFinalFields()
      Explains the relationship to ordinary final fields.
      Returns:
      a short comparison
    • status

      public String status()
      Describes the Java 26 maturity level.
      Returns:
      a short status note
    • previewBoundary

      public String previewBoundary()
      Explains why the preview API runs in a child process.
      Returns:
      the preview boundary