Class DevLoopAgent

java.lang.Object
com.vaadin.flow.devloop.agent.DevLoopAgent

public final class DevLoopAgent extends Object
Captures the Instrumentation handle at JVM startup and publishes it, so the in-app dev-loop connector can perform atomic class redefinitions in-process.

The daemon jar carries Premain-Class/Agent-Class pointing here alongside its own Main-Class, so one artifact is both the runnable daemon and the javaagent the application JVM loads. Only this class is ever loaded into the application JVM.

The handle is published two ways, so the connector finds it regardless of which class loader ends up owning the application classes: as a static field here (which works when the agent jar is visible to the application loader, the normal case since agent jars are appended to the system class path), and as a value in the system properties table, which is a Hashtable<Object, Object> and can therefore carry an arbitrary object - that path needs no class visibility at all.

Depends on nothing but java.instrument: it is loaded before the application, into a JVM whose class path it must not influence.

For internal use only. May be renamed or removed in a future release.

  • Field Details

  • Method Details

    • premain

      public static void premain(String args, Instrumentation inst)
      Entry point when the agent is loaded at JVM startup with -javaagent:.
      Parameters:
      args - the agent arguments, unused
      inst - the instrumentation handle to publish
    • agentmain

      public static void agentmain(String args, Instrumentation inst)
      Entry point when the agent is attached to a running JVM.
      Parameters:
      args - the agent arguments, unused
      inst - the instrumentation handle to publish
    • get

      public static Instrumentation get()
      The captured instrumentation handle, or null when this class was loaded without the agent having been installed.
      Returns:
      the instrumentation handle, or null