Class DispatchWriter

java.lang.Object
io.micronaut.inject.writer.AbstractClassFileWriter
io.micronaut.inject.writer.DispatchWriter
All Implemented Interfaces:
ClassOutputWriter, OriginatingElements, org.objectweb.asm.Opcodes

@Internal public final class DispatchWriter extends AbstractClassFileWriter implements org.objectweb.asm.Opcodes
Switch based dispatch writer.
Since:
3.1
Author:
Denis Stepanov
  • Constructor Details

    • DispatchWriter

      public DispatchWriter(org.objectweb.asm.Type thisType)
  • Method Details

    • addSetField

      public int addSetField(FieldElement beanField)
      Adds new set field dispatch target.
      Parameters:
      beanField - The field
      Returns:
      the target index
    • addGetField

      public int addGetField(FieldElement beanField)
      Adds new get field dispatch target.
      Parameters:
      beanField - The field
      Returns:
      the target index
    • addMethod

      public int addMethod(TypedElement declaringType, MethodElement methodElement)
      Adds new method dispatch target.
      Parameters:
      declaringType - The declaring type
      methodElement - The method element
      Returns:
      the target index
    • addMethod

      public int addMethod(TypedElement declaringType, MethodElement methodElement, boolean useOneDispatch)
      Adds new method dispatch target.
      Parameters:
      declaringType - The declaring type
      methodElement - The method element
      useOneDispatch - If method should be dispatched using "dispatchOne"
      Returns:
      the target index
    • addInterceptedMethod

      public int addInterceptedMethod(TypedElement declaringType, MethodElement methodElement, String interceptedProxyClassName, String interceptedProxyBridgeMethodName)
      Adds new interceptable method dispatch target.
      Parameters:
      declaringType - The declaring type
      methodElement - The method element
      interceptedProxyClassName - The interceptedProxyClassName
      interceptedProxyBridgeMethodName - The interceptedProxyBridgeMethodName
      Returns:
      the target index
    • addDispatchTarget

      public int addDispatchTarget(DispatchWriter.DispatchTarget dispatchTarget)
      Adds new custom dispatch target.
      Parameters:
      dispatchTarget - The dispatch target implementation
      Returns:
      the target index
    • buildDispatchMethod

      public void buildDispatchMethod(org.objectweb.asm.ClassWriter classWriter)
      Build dispatch method if needed.
      Parameters:
      classWriter - The classwriter
    • buildDispatchOneMethod

      public void buildDispatchOneMethod(org.objectweb.asm.ClassWriter classWriter)
      Build dispatch one method if needed.
      Parameters:
      classWriter - The classwriter
    • buildGetTargetMethodByIndex

      public void buildGetTargetMethodByIndex(org.objectweb.asm.ClassWriter classWriter)
      Build get target method by index method if needed.
      Parameters:
      classWriter - The classwriter
    • pushTypeUtilsGetRequiredMethod

      public static void pushTypeUtilsGetRequiredMethod(org.objectweb.asm.commons.GeneratorAdapter builder, org.objectweb.asm.Type declaringTypeObject, MethodElement methodElement)
    • accept

      public void accept(ClassWriterOutputVisitor classWriterOutputVisitor) throws IOException
      Description copied from interface: ClassOutputWriter
      Accept a ClassWriterOutputVisitor to write this writer to disk.
      Specified by:
      accept in interface ClassOutputWriter
      Parameters:
      classWriterOutputVisitor - The ClassWriterOutputVisitor
      Throws:
      IOException - if there is an error writing to disk
    • getDispatchTargets

      public List<DispatchWriter.DispatchTarget> getDispatchTargets()
      Returns:
      all added dispatch targets
    • isHasInterceptedMethod

      public boolean isHasInterceptedMethod()
      Returns:
      if intercepted method dispatch have been added