Class BytecodeScanner


  • public class BytecodeScanner
    extends java.lang.Object
    Scan the raw bytecodes of a method. This is useful in order to find out quickly whether or not a method uses particular instructions.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  BytecodeScanner.Callback
      Callback interface to report scanned instructions.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static boolean DEBUG  
      private static int[] PAD  
    • Constructor Summary

      Constructors 
      Constructor Description
      BytecodeScanner()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static int extractInt​(byte[] arr, int offset)
      Extract an int from bytes at the given offset in the array.
      void scan​(byte[] instructionList, BytecodeScanner.Callback callback)
      Scan the raw bytecodes of a method.
      private static short unsignedValueOf​(byte value)
      Convert the unsigned value of a byte into a short.
      • Methods inherited from class java.lang.Object

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

      • DEBUG

        private static final boolean DEBUG
      • PAD

        private static final int[] PAD
    • Constructor Detail

      • BytecodeScanner

        public BytecodeScanner()
    • Method Detail

      • unsignedValueOf

        private static short unsignedValueOf​(byte value)
        Convert the unsigned value of a byte into a short.
        Parameters:
        value - the byte
        Returns:
        the byte's unsigned value as a short
      • extractInt

        private static int extractInt​(byte[] arr,
                                      int offset)
        Extract an int from bytes at the given offset in the array.
        Parameters:
        arr - the array
        offset - the offset in the array
      • scan

        public void scan​(byte[] instructionList,
                         BytecodeScanner.Callback callback)
        Scan the raw bytecodes of a method.
        Parameters:
        instructionList - the bytecodes
        callback - the callback object