Class ClassGeneratorOptions

java.lang.Object
org.jfuncmachine.compiler.classgen.ClassGeneratorOptions

public class ClassGeneratorOptions extends Object
Contains the options for code generation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final boolean
    Indicates whether the code generator should automatically convert between native types and boxed types (Object-versions of each type, e.g.
    final boolean
    The TypeSwitch and EnumSwitch expressions use a feature that was a preview in Java 17, and became fully supported in Java 21.
    final boolean
    Generate non-Java-callable methods with tail-call optimization.
    final boolean
    Indicate whether to generate Java-compatible generic object interfaces for each lambda.
    final int
    The Java version to generate class files for
    final String
    The name used for the single method in a lambda interface.
    final boolean
    Convert local recursive calls (method calling itself) to loops
    final boolean
    Indicates that any lambdas generated for one class can be shared by all classes in the same package.
    final boolean
    Currently JFuncMachine uses two features that were previews between Java 17 and Java 21.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a ClassGeneratorOptions instance with the default settings
    ClassGeneratorOptions(int javaVersion, boolean localTailCallsToLoops, boolean fullTailCalls, boolean autobox, boolean sharedLambdaInterfaces, String lambdaMethodName, boolean genericLambdas, boolean usePreviewFeatures, boolean convertSwitchesToIf)
    Create a ClassGeneratorOptions instance with specific settings
  • Method Summary

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • javaVersion

      public final int javaVersion
      The Java version to generate class files for
    • localTailCallsToLoops

      public final boolean localTailCallsToLoops
      Convert local recursive calls (method calling itself) to loops
    • fullTailCalls

      public final boolean fullTailCalls
      Generate non-Java-callable methods with tail-call optimization. This requires changing the return type of each method to return an object that contains a reference to the next function to call, or a value representing the return value of the function. This option should not be used unless it is really needed as it adds overhead to each function call.
    • autobox

      public final boolean autobox
      Indicates whether the code generator should automatically convert between native types and boxed types (Object-versions of each type, e.g. java.lang.Byte for byte, java.lang.Integer for int).
    • sharedLambdaInterfaces

      public final boolean sharedLambdaInterfaces
      Indicates that any lambdas generated for one class can be shared by all classes in the same package. Since the names of the lambdas are dependent on their types, two classes using the sames types for a lambda should be able to share a single interface definition.
    • lambdaMethodName

      public final String lambdaMethodName
      The name used for the single method in a lambda interface.
    • genericLambdas

      public final boolean genericLambdas
      Indicate whether to generate Java-compatible generic object interfaces for each lambda. This facilitates lambdas that are compatible with the java.util.function package.
    • usePreviewFeatures

      public final boolean usePreviewFeatures
      Currently JFuncMachine uses two features that were previews between Java 17 and Java 21. If this option is true, JFuncMachine will use these features if generating for Java versions 17, 18, 19, and 20.
    • convertSwitchesToIf

      public final boolean convertSwitchesToIf
      The TypeSwitch and EnumSwitch expressions use a feature that was a preview in Java 17, and became fully supported in Java 21. If this flag is true, JFuncMachine will convert these expressions to If expressions if generating for a JVM where the feature is not supported. If usePreviewFeatures is true, then this conversion will only happen for Java 16 or lower. If usePreviewFeatures is false, then this conversion will happen for Java 20 or lower.
  • Constructor Details

    • ClassGeneratorOptions

      public ClassGeneratorOptions()
      Create a ClassGeneratorOptions instance with the default settings
    • ClassGeneratorOptions

      public ClassGeneratorOptions(int javaVersion, boolean localTailCallsToLoops, boolean fullTailCalls, boolean autobox, boolean sharedLambdaInterfaces, String lambdaMethodName, boolean genericLambdas, boolean usePreviewFeatures, boolean convertSwitchesToIf)
      Create a ClassGeneratorOptions instance with specific settings
      Parameters:
      javaVersion - The Java version to generate class files for
      localTailCallsToLoops - Convert local recursive calls (method calling itself) to loops
      fullTailCalls - Generate non-Java-callable methods with tail-call optimization
      autobox - Automatically box and unbox types as needed
      sharedLambdaInterfaces - Any lambdas generated for one class can be shared by all classes in the same package
      lambdaMethodName - The name used for the single method in a lambda interface
      genericLambdas - generate Java-compatible generic object interfaces for each lambda
      usePreviewFeatures - Use features that are only available as a preview in the target Java version
      convertSwitchesToIf - Automatically convert type and enum switches to if expressions if the Java version doesn't support them