public class StaticTypesSwitchExpressionWriter
extends SwitchExpressionWriter
Static-compilation writer for SwitchExpression. Emits
tableswitch / lookupswitch when the selector and labels are
constants of a type javac would switch on, and otherwise the
isCase method selected by the type checker as a direct call.
| Fields inherited from class | Fields |
|---|---|
class SwitchExpressionWriter |
controller |
| Constructor and description |
|---|
StaticTypesSwitchExpressionWriter(StaticTypesWriterController controller)Creates a switch-expression writer for statically compiled methods. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected ClassNode |
prepareSelectorType(OperandStack operandStack)Keeps the selector as visited — boxing is deferred until a path actually needs a reference (isCase or a null check on a wrapper). |
|
protected void |
writeIsCaseComparison(CaseStatement caseStatement, int selectorIndex, ClassNode selectorType)Emits the isCase call selected by the type checker as a direct
method call via AsmClassGenerator.visitMethodCallExpression,
which reaches StaticInvocationWriter.writeDirectMethodCall.
|
|
protected boolean |
writeOptimizedSwitch(SwitchExpression expression, int selectorIndex, ClassNode selectorType) |
| Methods inherited from class | Name |
|---|---|
class SwitchExpressionWriter |
enumConstantCount, enumConstantName, intConstant, isIntegralType, isIntegralWrapper, prepareSelectorType, resolveResultType, stringConstant, throwIncompatibleClassChangeError, throwUnmatchedSelector, unwrapEnumType, writeDefaultOrThrow, writeIsCaseComparison, writeOptimizedSwitch, writeSwitchExpression, writeYield |
Creates a switch-expression writer for statically compiled methods.
controller - the static types writer controllerKeeps the selector as visited — boxing is deferred until a path actually needs a reference (isCase or a null check on a wrapper).
Emits the isCase call selected by the type checker as a direct
method call via AsmClassGenerator.visitMethodCallExpression,
which reaches StaticInvocationWriter.writeDirectMethodCall.
A literal case null is identity, not DGM.isCase(Object,Object)
(which NPEs). Any other arm must already carry
StaticTypesMarker.DIRECT_METHOD_CALL_TARGET on the
CaseStatement; missing targets are a type-checking error except
under TypeCheckingMode.SKIP.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.