Class ClassGeneratorOptions
java.lang.Object
org.jfuncmachine.compiler.classgen.ClassGeneratorOptions
Contains the options for code generation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal booleanIndicates whether the code generator should automatically convert between native types and boxed types (Object-versions of each type, e.g.final booleanThe TypeSwitch and EnumSwitch expressions use a feature that was a preview in Java 17, and became fully supported in Java 21.final booleanGenerate non-Java-callable methods with tail-call optimization.final booleanIndicate whether to generate Java-compatible generic object interfaces for each lambda.final intThe Java version to generate class files forfinal StringThe name used for the single method in a lambda interface.final booleanConvert local recursive calls (method calling itself) to loopsfinal booleanIndicates that any lambdas generated for one class can be shared by all classes in the same package.final booleanCurrently JFuncMachine uses two features that were previews between Java 17 and Java 21. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a ClassGeneratorOptions instance with the default settingsClassGeneratorOptions(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
-
Field Details
-
javaVersion
public final int javaVersionThe Java version to generate class files for -
localTailCallsToLoops
public final boolean localTailCallsToLoopsConvert local recursive calls (method calling itself) to loops -
fullTailCalls
public final boolean fullTailCallsGenerate 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 autoboxIndicates 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). -
lambdaMethodName
The name used for the single method in a lambda interface. -
genericLambdas
public final boolean genericLambdasIndicate 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 usePreviewFeaturesCurrently 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 convertSwitchesToIfThe 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 forlocalTailCallsToLoops- Convert local recursive calls (method calling itself) to loopsfullTailCalls- Generate non-Java-callable methods with tail-call optimizationautobox- Automatically box and unbox types as neededsharedLambdaInterfaces- Any lambdas generated for one class can be shared by all classes in the same packagelambdaMethodName- The name used for the single method in a lambda interfacegenericLambdas- generate Java-compatible generic object interfaces for each lambdausePreviewFeatures- Use features that are only available as a preview in the target Java versionconvertSwitchesToIf- Automatically convert type and enum switches to if expressions if the Java version doesn't support them
-