Class BytecodeTransformerBuildItem

java.lang.Object
io.quarkus.builder.item.BuildItem
io.quarkus.builder.item.MultiBuildItem
io.quarkus.deployment.builditem.BytecodeTransformerBuildItem

public final class BytecodeTransformerBuildItem extends MultiBuildItem
  • Field Details

    • eager

      final boolean eager
      If this is true it means the class should be loaded eagerly by a thread pool in dev mode on multithreaded systems.

      Transformation is expensive, so doing it this way can speed up boot time.

    • classToTransform

      final String classToTransform
    • visitorFunction

      final BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction
    • inputTransformer

      final BiFunction<String,byte[],byte[]> inputTransformer
      Function that can be applied to the input bytes before it is passed into ASM. This should only be used in very specific circumstances. At the moment the only known valid use case is JaCoCo, which needs access to the unmodified class file bytes.
    • requireConstPoolEntry

      final Set<String> requireConstPoolEntry
      A set of class names that need to be present in the const pool for the transformation to happen. These need to be in JVM internal format.

      The transformation is only applied if at least one of the entries in the const pool is present.

      Note that this is an optimisation, and if another transformer is transforming the class anyway then this transformer will always be applied.

    • cacheable

      final boolean cacheable
    • classReaderOptions

      final int classReaderOptions
    • continueOnFailure

      final boolean continueOnFailure
    • priority

      final int priority
  • Constructor Details

    • BytecodeTransformerBuildItem

      public BytecodeTransformerBuildItem(String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction)
    • BytecodeTransformerBuildItem

      public BytecodeTransformerBuildItem(String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, Set<String> requireConstPoolEntry)
    • BytecodeTransformerBuildItem

      public BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction)
    • BytecodeTransformerBuildItem

      public BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, boolean cacheable)
    • BytecodeTransformerBuildItem

      public BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, Set<String> requireConstPoolEntry)
    • BytecodeTransformerBuildItem

      public BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, Set<String> requireConstPoolEntry, boolean cacheable)
    • BytecodeTransformerBuildItem

      public BytecodeTransformerBuildItem(BytecodeTransformerBuildItem.Builder builder)
  • Method Details

    • getClassToTransform

      public String getClassToTransform()
    • getVisitorFunction

      public BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> getVisitorFunction()
    • getRequireConstPoolEntry

      public Set<String> getRequireConstPoolEntry()
    • isEager

      public boolean isEager()
    • isCacheable

      public boolean isCacheable()
    • getClassReaderOptions

      public int getClassReaderOptions()
    • getInputTransformer

      public BiFunction<String,byte[],byte[]> getInputTransformer()
    • isContinueOnFailure

      public boolean isContinueOnFailure()
    • getPriority

      public int getPriority()
      Bytecode transformers are applied in ascending priority order. That is, lower priority value means the transformer is applied sooner, and higher priority value means the transformer is applied later.

      This applies directly to inputTransformer functions: an input transformer function with lower priority is applied first and its result is passed to the transformer function with higher priority.

      It is a bit counter-intuitive when it comes to the visitorFunction. The visitor function doesn't directly transform bytecode; instead, it constructs an ASM ClassVisitor from an earlier class visitor. This means that the priority order is effectively turned around: the later a bytecode transformer is called, the higher in the class visitor chain it ends up, and the sooner is the visitor eventually called.

      The priority value defaults to 0.