Package 

Object ByteCodeUtils


  • 
    public class ByteCodeUtils
    
                        

    A common set of utilities that might be needed for doing work with JVM Bytecode.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public final class ByteCodeUtils.MethodSignature

      Represents a method signature and its 3 parts; A name, a description(parameters) and a (optional) return type.

    • Method Summary

      Modifier and Type Method Description
      final String runtimeSignature(Method method) Parses the runtime signature of the given method.
      final Character primitiveType(Class<?> cls) Returns the primitive type char for the given class.
      final Class<?> primitiveType(Character c) Takes a primitive char type and returns the corresponding class associated with it, or null if the char is not a primitive type.
      final String toRuntimeName(Class<?> type) Parses the name of a given class into the runtime format.
      final Boolean isPrimitiveType(Character c) Determines if the given char can be parsed to a primitive type.
      final Boolean isReturn(Integer opcode) Determines if the given opcode is a return instruction.
      final Boolean sameSignature(String first, String second) Determines if the two strings have the same name and description, ignoring the return type.
      final String byteCodeSignature(Method method) Returns the runtime method signature of the provided method.
      • Methods inherited from class java.lang.Object

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

      • runtimeSignature

         final String runtimeSignature(Method method)

        Parses the runtime signature of the given method.

        Parameters:
        method - The method to parse.
      • primitiveType

         final Character primitiveType(Class<?> cls)

        Returns the primitive type char for the given class. If the given class is not a primitive then null is returned.

        Parameters:
        cls - The class to find the primitive type of.
      • primitiveType

         final Class<?> primitiveType(Character c)

        Takes a primitive char type and returns the corresponding class associated with it, or null if the char is not a primitive type.

        Parameters:
        c - the char to find a primitive class of.
      • toRuntimeName

         final String toRuntimeName(Class<?> type)

        Parses the name of a given class into the runtime format.

        Parameters:
        type - The class to get the runtime name of
      • isPrimitiveType

         final Boolean isPrimitiveType(Character c)

        Determines if the given char can be parsed to a primitive type.

        Parameters:
        c - the given char.
      • isReturn

         final Boolean isReturn(Integer opcode)

        Determines if the given opcode is a return instruction.

        Parameters:
        opcode - The opcode to check against.
      • sameSignature

         final Boolean sameSignature(String first, String second)

        Determines if the two strings have the same name and description, ignoring the return type. Note, a return type does not have to be present at all for this to work.

        Parameters:
        first - the first signature to match against.
        second - the second signature to match against.
      • byteCodeSignature

         final String byteCodeSignature(Method method)

        Returns the runtime method signature of the provided method.

        Parameters:
        method - The method to parse the name of.