Class PatternSwitchDesugar

  • All Implemented Interfaces:
    ASTTransform

    public class PatternSwitchDesugar
    extends Object
    implements ASTTransform
    Desugars a Java 21 pattern-matching switch expression into the SwitchBootstraps.typeSwitch invokedynamic and an integer dispatch switch.
    • Constructor Detail

      • PatternSwitchDesugar

        public PatternSwitchDesugar()
        Creates a desugarer with no class pool, so record-component lookups are unavailable.
      • PatternSwitchDesugar

        public PatternSwitchDesugar​(ClassPool classPool)
        Creates a desugarer that resolves record components through a pool.
        Parameters:
        classPool - the pool used to read Record attributes, or null
    • Method Detail

      • getName

        public String getName()
        Specified by:
        getName in interface ASTTransform
        Returns:
        the name of this transform for logging/debugging
      • transform

        public boolean transform​(BlockStmt block)
        Description copied from interface: ASTTransform
        Transforms the given block statement in place.
        Specified by:
        transform in interface ASTTransform
        Parameters:
        block - the block to transform
        Returns:
        true if any changes were made