Class AnnotationLiteralProcessor


  • public class AnnotationLiteralProcessor
    extends Object
    Handles generating bytecode for annotation literals. The create() method can be used to generate a bytecode sequence for instantiating an annotation literal.

    Behind the scenes, for each annotation literal, its class is also generated. This class is supposed to be used at runtime. The generated annotation literal classes are shared. That is, one class is generated for each annotation type and the constructor of that class accepts values of all annotation members. As a special case, annotation literal classes for memberless annotation types have a singleton instance.

    This construct is thread-safe.

    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      io.quarkus.gizmo.ResultHandle create​(io.quarkus.gizmo.BytecodeCreator bytecode, org.jboss.jandex.ClassInfo annotationClass, org.jboss.jandex.AnnotationInstance annotationInstance)
      Generates a bytecode sequence to create an instance of given annotation type, such that the annotation members have the same values as the given annotation instance.
      io.quarkus.gizmo.ResultHandle process​(io.quarkus.gizmo.BytecodeCreator bytecode, io.quarkus.gizmo.ClassOutput classOutput, org.jboss.jandex.ClassInfo annotationClass, org.jboss.jandex.AnnotationInstance annotationInstance, String targetPackage)
      Deprecated.
      annotation literal sharing is now always enabled, this method is superseded by create(BytecodeCreator, ClassInfo, AnnotationInstance) and will be removed at some time after Quarkus 3.0
    • Method Detail

      • process

        @Deprecated
        public io.quarkus.gizmo.ResultHandle process​(io.quarkus.gizmo.BytecodeCreator bytecode,
                                                     io.quarkus.gizmo.ClassOutput classOutput,
                                                     org.jboss.jandex.ClassInfo annotationClass,
                                                     org.jboss.jandex.AnnotationInstance annotationInstance,
                                                     String targetPackage)
        Deprecated.
        annotation literal sharing is now always enabled, this method is superseded by create(BytecodeCreator, ClassInfo, AnnotationInstance) and will be removed at some time after Quarkus 3.0
      • create

        public io.quarkus.gizmo.ResultHandle create​(io.quarkus.gizmo.BytecodeCreator bytecode,
                                                    org.jboss.jandex.ClassInfo annotationClass,
                                                    org.jboss.jandex.AnnotationInstance annotationInstance)
        Generates a bytecode sequence to create an instance of given annotation type, such that the annotation members have the same values as the given annotation instance. An implementation of the annotation type will be generated automatically.

        We call the generated implementation of the annotation type an annotation literal class and the instance produced by the generated bytecode an annotation literal instance, even though the generated code doesn't use CDI's AnnotationLiteral anymore.

        Parameters:
        bytecode - will receive the bytecode sequence for instantiating the annotation literal class as a sequence of BytecodeCreator method calls
        annotationClass - the annotation type
        annotationInstance - the annotation instance; must match the annotationClass
        Returns:
        an annotation literal instance result handle