Class AnnotationMetadataWriter

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

@Internal public class AnnotationMetadataWriter extends AbstractClassFileWriter
Responsible for writing class files that are instances of AnnotationMetadata.
Since:
1.0
Author:
Graeme Rocher
  • Constructor Details

    • AnnotationMetadataWriter

      @Deprecated public AnnotationMetadataWriter(String className, ClassElement originatingElement, AnnotationMetadata annotationMetadata, boolean writeAnnotationDefaults)
      Deprecated.
      No longer needs to be instantiated directly, just use the static methods
      Constructs a new writer for the given class name and metadata.
      Parameters:
      className - The class name for which the metadata relates
      originatingElement - The originating element
      annotationMetadata - The annotation metadata
      writeAnnotationDefaults - Whether annotations defaults should be written
    • AnnotationMetadataWriter

      @Deprecated public AnnotationMetadataWriter(String className, ClassElement originatingElement, AnnotationMetadata annotationMetadata)
      Deprecated.
      No longer needs to be instantiated directly, just use the static methods
      Constructs a new writer for the given class name and metadata.
      Parameters:
      className - The class name for which the metadata relates
      originatingElement - The originating element
      annotationMetadata - The annotation metadata
  • Method Details

    • getClassName

      public String getClassName()
      Returns:
      The class name that this metadata will generate
    • accept

      public void accept(ClassWriterOutputVisitor outputVisitor) throws IOException
      Accept an ClassWriterOutputVisitor to write all generated classes.
      Parameters:
      outputVisitor - The ClassWriterOutputVisitor
      Throws:
      IOException - If an error occurs
    • writeTo

      public void writeTo(OutputStream outputStream)
      Write the class to the output stream, such a JavaFileObject created from a java annotation processor Filer object.
      Parameters:
      outputStream - the output stream pointing to the target class file
    • instantiateNewMetadata

      @Internal public static void instantiateNewMetadata(org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, MutableAnnotationMetadata annotationMetadata, Map<String,Integer> defaultsStorage, Map<String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)
      Writes out the byte code necessary to instantiate the given MutableAnnotationMetadata.
      Parameters:
      owningType - The owning type
      declaringClassWriter - The declaring class writer
      generatorAdapter - The generator adapter
      annotationMetadata - The annotation metadata
      defaultsStorage - The annotation defaults
      loadTypeMethods - The generated load type methods
    • instantiateNewMetadataHierarchy

      @Internal public static void instantiateNewMetadataHierarchy(org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter classWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, AnnotationMetadataHierarchy hierarchy, Map<String,Integer> defaultsStorage, Map<String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)
      Writes out the byte code necessary to instantiate the given AnnotationMetadataHierarchy.
      Parameters:
      owningType - The owning type
      classWriter - The declaring class writer
      generatorAdapter - The generator adapter
      hierarchy - The annotation metadata
      defaultsStorage - The annotation defaults
      loadTypeMethods - The generated load type methods
    • pushAnnotationMetadataReference

      @Internal public static void pushAnnotationMetadataReference(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, AnnotationMetadataReference annotationMetadata)
      Pushes an annotation metadata reference.
      Parameters:
      generatorAdapter - The generator adapter
      annotationMetadata - The metadata
    • writeAnnotationDefaults

      @Internal public static void writeAnnotationDefaults(MutableAnnotationMetadata annotationMetadata, org.objectweb.asm.ClassWriter classWriter, org.objectweb.asm.Type owningType, Map<String,Integer> defaultsStorage, Map<String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)
      Writes out the byte code necessary to instantiate the given MutableAnnotationMetadata.
      Parameters:
      annotationMetadata - The annotation metadata
      classWriter - The class writer
      owningType - The owning type
      defaultsStorage - The annotation defaults
      loadTypeMethods - The generated load type methods
    • writeAnnotationDefaults

      @Internal public static void writeAnnotationDefaults(org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter classWriter, org.objectweb.asm.commons.GeneratorAdapter staticInit, MutableAnnotationMetadata annotationMetadata, Map<String,Integer> defaultsStorage, Map<String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)
      Write annotation defaults into the given static init block.
      Parameters:
      owningType - The owning type
      classWriter - The class writer
      staticInit - The staitc init
      annotationMetadata - The annotation metadata
      defaultsStorage - The annotation defaults
      loadTypeMethods - The load type methods
    • isSupportedMapValue

      public static boolean isSupportedMapValue(Object value)
    • invokeLoadClassValueMethod

      public static void invokeLoadClassValueMethod(org.objectweb.asm.Type declaringType, org.objectweb.asm.ClassVisitor declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter methodVisitor, Map<String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods, AnnotationClassValue acv)