public sealed interface Gizmo
A simplified class file writer.
-
Method Summary
Modifier and TypeMethodDescriptionclass_(ClassDesc desc, Consumer<ClassCreator> builder) Add a new class.default ClassDescclass_(String name, Consumer<ClassCreator> builder) Add a new class.static Gizmocreate(ClassOutput outputHandler) Returns a new Gizmo which outputs to the given handler by default.interface_(ClassDesc desc, Consumer<InterfaceCreator> builder) Add a new interface.default ClassDescinterface_(String name, Consumer<InterfaceCreator> builder) Add a new interface.withDebugInfo(boolean debugInfo) Returns a Gizmo instance which has debug info output enabled or disabled.withDefaultModifiers(Consumer<ModifierConfigurator> builder) Returns a Gizmo instance which uses the default modifiers configured by the given configurator.withLambdasAsAnonymousClasses(boolean lambdasAsAnonymousClasses) Returns a Gizmo instance which emits lambdas as anonymous classes if the parameter istrue.withOutput(ClassOutput outputHandler) Returns a Gizmo instance which uses the given output handler.withParameters(boolean parameters) Returns a Gizmo instance which has parameters output enabled or disabled.
-
Method Details
-
create
Returns a new Gizmo which outputs to the given handler by default.- Parameters:
outputHandler- the output handler (must not benull)- Returns:
- a new Gizmo which outputs to the given handler by default
-
withOutput
Returns a Gizmo instance which uses the given output handler.- Parameters:
outputHandler- the output handler (must not benull)- Returns:
- a Gizmo instance which uses the given output handler
-
withDebugInfo
Returns a Gizmo instance which has debug info output enabled or disabled.By default, debug info is included.
- Parameters:
debugInfo-trueto include debug info, orfalseto exclude debug info- Returns:
- a Gizmo instance which has debug info output enabled or disabled
-
withParameters
Returns a Gizmo instance which has parameters output enabled or disabled. This setting affects whether method parameter names are recorded in aMethodParametersattribute, which is separate from debug info and appears when using runtime reflection. Some frameworks require this attribute to be present.By default, parameter name info is included.
- Parameters:
parameters-trueto include parameter name info, orfalseto exclude parameter name info- Returns:
- a Gizmo instance which has parameters output enabled or disabled
-
withLambdasAsAnonymousClasses
Returns a Gizmo instance which emits lambdas as anonymous classes if the parameter istrue. When enabled, lambda bodies are not generated into synthetic methods on the generated class, but into additional anonymous classes. Further, lambda instances are not obtained through invokedynamic, but through regular instantiation of the additional anonymous classes.This doesn't affect runtime semantics of generated code, but it does affect the number of generated classes and, as of this writing, also runtime memory consumption.
By default, lambdas are not generated as anonymous classes.
- Parameters:
lambdasAsAnonymousClasses- whether lambdas should be generated as anonymous classes- Returns:
- a Gizmo instance which emits lambdas as anonymous classes if the parameter is
true
-
withDefaultModifiers
Returns a Gizmo instance which uses the default modifiers configured by the given configurator.- Parameters:
builder- the builder for the defaults (must not benull)- Returns:
- a Gizmo instance which uses the default modifiers configured by the given configurator
-
class_
Add a new class.- Parameters:
name- the fully qualified (dot-separated) binary class name (must not benull)builder- the builder for the class (must not benull)- Returns:
- the descriptor of the created class (not
null)
-
class_
Add a new class.- Parameters:
desc- the class descriptor (must not benull)builder- the builder for the class (must not benull)- Returns:
- the descriptor given for
desc
-
interface_
Add a new interface.- Parameters:
name- the fully qualified (dot-separated) binary class namebuilder- the builder for the interface (must not benull)- Returns:
- the descriptor of the created interface (not
null)
-
interface_
Add a new interface.- Parameters:
desc- the class descriptor (must not benull)builder- the builder for the class (must not benull)- Returns:
- the descriptor given for
desc
-