Class BufferAlignmentAgent


  • public class BufferAlignmentAgent
    extends java.lang.Object
    A Java agent that verifies that all memory accesses in DirectBuffer implementations are aligned.

    Unaligned accesses can be slower or even make the JVM crash on some architectures.

    Using this agent will avoid such crashes, but it has a performance overhead and should only be used for testing and debugging.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static net.bytebuddy.agent.builder.ResettableClassFileTransformer alignmentTransformer  
      private static java.lang.instrument.Instrumentation instrumentation  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static void agent​(boolean shouldRedefine, java.lang.instrument.Instrumentation instrumentation)  
      static void agentmain​(java.lang.String agentArgs, java.lang.instrument.Instrumentation instrumentation)
      Invoked when the agent is attached to an already running application.
      static void premain​(java.lang.String agentArgs, java.lang.instrument.Instrumentation instrumentation)
      Invoked when the agent is launched with the JVM and before the main application.
      static void removeTransformer()
      Remove the bytecode transformer and associated bytecode weaving so the alignment checks are not made.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • alignmentTransformer

        private static net.bytebuddy.agent.builder.ResettableClassFileTransformer alignmentTransformer
      • instrumentation

        private static java.lang.instrument.Instrumentation instrumentation
    • Constructor Detail

      • BufferAlignmentAgent

        public BufferAlignmentAgent()
    • Method Detail

      • premain

        public static void premain​(java.lang.String agentArgs,
                                   java.lang.instrument.Instrumentation instrumentation)
        Invoked when the agent is launched with the JVM and before the main application.
        Parameters:
        agentArgs - ignored for buffer alignment agent.
        instrumentation - for adding bytecode to classes.
      • agentmain

        public static void agentmain​(java.lang.String agentArgs,
                                     java.lang.instrument.Instrumentation instrumentation)
        Invoked when the agent is attached to an already running application.
        Parameters:
        agentArgs - ignored for buffer alignment agent.
        instrumentation - for adding bytecode to classes.
      • agent

        private static void agent​(boolean shouldRedefine,
                                  java.lang.instrument.Instrumentation instrumentation)
      • removeTransformer

        public static void removeTransformer()
        Remove the bytecode transformer and associated bytecode weaving so the alignment checks are not made.