java.lang.Object
io.opentelemetry.javaagent.tooling.instrumentation.indy.IndyBootstrap

public class IndyBootstrap extends Object
We instruct Byte Buddy (via Advice.WithCustomMapping.bootstrap(java.lang.reflect.Method)) to dispatch non-inlined advices via an invokedynamic (indy) instruction. The target method is linked to a dynamically created instrumentation module class loader that is specific to an instrumentation module and the class loader of the instrumented method.

The first invocation of an INVOKEDYNAMIC causes the JVM to dynamically link a CallSite. In this case, it will use the bootstrap(java.lang.invoke.MethodHandles.Lookup, java.lang.String, java.lang.invoke.MethodType, java.lang.Object[]) method to do that. This will also create the InstrumentationModuleClassLoader.


   Bootstrap CL ←──────────────────────────── Agent CL
       ↑ └───────── IndyBootstrapDispatcher ─ ↑ ──→ └────────────── bootstrap(java.lang.invoke.MethodHandles.Lookup, java.lang.String, java.lang.invoke.MethodType, java.lang.Object[])
     Ext/Platform CL               ↑          │                        ╷
       ↑                           ╷          │                        ↓
     System CL                     ╷          │        IndyModuleRegistry.getInstrumentationClassloader(String, ClassLoader)
       ↑                           ╷          │                        ╷
     Common               linking of CallSite │                        ╷
     ↑    ↑             (on first invocation) │                        ╷
 WebApp1  WebApp2                  ╷          │                     creates
          ↑ - InstrumentedClass    ╷          │                        ╷
          │                ╷       ╷          │                        ╷
          │                INVOKEDYNAMIC      │                        ↓
          └────────────────┼──────────────────InstrumentationModuleClassLoader
                           └╶╶╶╶╶╶╶╶╶╶╶╶╶╶╶╶╶╶╶╶╶→├ AdviceClass
                                                  ├ AdviceHelper
                                                  └ LookupExposer

 Legend:
  ╶╶→ method calls
  ──→ class loader parent/child relationships
 
  • Method Details

    • getIndyBootstrapMethod

      public static Method getIndyBootstrapMethod()
    • getProxyFactory

      public static IndyProxyFactory getProxyFactory(io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule instrumentationModule)
      Creates a proxy factory for generating proxies for classes which are loaded by an InstrumentationModuleClassLoader for the provided InstrumentationModule.
      Parameters:
      instrumentationModule - the instrumentation module used to load the proxied target classes
      Returns:
      a factory for generating proxy classes