Class AnnotationLiteralProcessor
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
Modifier and TypeMethodDescriptionio.quarkus.gizmo.ResultHandlecreate(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.
-
Method Details
-
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.It is expected that given annotation instance is runtime-retained; an exception is thrown if not. Further, it is expected that the annotation type is available (that is,
annotationClass != null); an exception is thrown if not. Callers that expect they always deal with runtime-retained annotations whose classes are available do not have to check (and will get decent errors for free), but callers that can possibly deal with class-retained annotations or missing annotation classes must check explicitly.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
AnnotationLiteralanymore.- Parameters:
bytecode- will receive the bytecode sequence for instantiating the annotation literal class as a sequence ofBytecodeCreatormethod callsannotationClass- the annotation typeannotationInstance- the annotation instance; must match theannotationClass- Returns:
- an annotation literal instance result handle
-