Class BytecodeRecorderImpl

  • All Implemented Interfaces:
    RecorderContext

    public class BytecodeRecorderImpl
    extends Object
    implements RecorderContext
    A class that can be used to record invocations to bytecode so they can be replayed later. This is done through the use of class recorders and recording proxies.

    A class recorder is simply a stateless class with a no arg constructor. This recorder will contain the runtime logic used to bootstrap the various frameworks.

    A recording proxy is a proxy of a recorder that records all invocations on the recorder, and then writes out a sequence of java bytecode that performs the same invocations.

    There are some limitations on what can be recorded. Only the following objects are allowed as parameters to recording proxies:

    - primitives - String - Class - Objects returned from a previous recorder invocation - Objects with a no-arg constructor and getter/setters for all properties (or public fields) - Objects with a constructor annotated with @RecordableConstructor with parameter names that match field names - Any arbitrary object via the registerSubstitution(Class, Class, Class) mechanism - arrays, lists and maps of the above

    • Constructor Detail

      • BytecodeRecorderImpl

        public BytecodeRecorderImpl​(boolean staticInit,
                                    String buildStepName,
                                    String methodName,
                                    String uniqueHash)
      • BytecodeRecorderImpl

        BytecodeRecorderImpl​(ClassLoader classLoader,
                             boolean staticInit,
                             String className)
      • BytecodeRecorderImpl

        public BytecodeRecorderImpl​(ClassLoader classLoader,
                                    boolean staticInit,
                                    String className,
                                    Function<io.quarkus.gizmo.ClassOutput,​io.quarkus.gizmo.ClassCreator> classCreatorFunction,
                                    Function<io.quarkus.gizmo.ClassCreator,​io.quarkus.gizmo.MethodCreator> methodCreatorFunction)
    • Method Detail

      • isEmpty

        public boolean isEmpty()
      • registerSubstitution

        public <F,​T> void registerSubstitution​(Class<F> from,
                                                     Class<T> to,
                                                     Class<? extends ObjectSubstitution<F,​T>> substitution)
        Description copied from interface: RecorderContext
        Registers a substitution to allow objects that are not serialisable to bytecode to be substituted for an object that is.
        Specified by:
        registerSubstitution in interface RecorderContext
        Parameters:
        from - The class of the non serializable object
        to - The class to serialize to
        substitution - The subclass of ObjectSubstitution that performs the substitution
      • registerNonDefaultConstructor

        public <T> void registerNonDefaultConstructor​(Constructor<T> constructor,
                                                      Function<T,​List<Object>> parameters)
        Description copied from interface: RecorderContext
        Registers a way to construct an object via a non-default constructor. Each object may only have at most one non-default constructor registered
        Specified by:
        registerNonDefaultConstructor in interface RecorderContext
        Type Parameters:
        T - The type of the object
        Parameters:
        constructor - The constructor
        parameters - A function that maps the object to a list of constructor parameters
      • classProxy

        public Class<?> classProxy​(String name)
        Description copied from interface: RecorderContext
        Creates a Class instance that can be passed to a recording proxy as a substitute for a class that is not loadable at processing time. At runtime the actual class will be passed into the invoked method.
        Specified by:
        classProxy in interface RecorderContext
        Parameters:
        name - The class name
        Returns:
        A Class instance that can be passed to a recording proxy
      • newInstance

        public <T> RuntimeValue<T> newInstance​(String name)
        Description copied from interface: RecorderContext
        Creates a RuntimeValue object that represents an object created via the default constructor.

        This object can be passed into recorders, but must not be used directly at deployment time

        Specified by:
        newInstance in interface RecorderContext
        Type Parameters:
        T - The type of the class
        Parameters:
        name - The name of the class
        Returns:
        The class instance proxy
      • getRecordingProxy

        public <T> T getRecordingProxy​(Class<T> theClass)
      • getClassName

        public String getClassName()
      • writeBytecode

        public void writeBytecode​(io.quarkus.gizmo.ClassOutput classOutput)
      • arrayValue

        static io.quarkus.gizmo.ResultHandle arrayValue​(org.jboss.jandex.AnnotationValue value,
                                                        io.quarkus.gizmo.BytecodeCreator valueMethod,
                                                        org.jboss.jandex.MethodInfo method,
                                                        org.jboss.jandex.ClassInfo annotationClass)
      • componentType

        static String componentType​(org.jboss.jandex.MethodInfo method)