Class MethodComparator


  • public class MethodComparator
    extends java.lang.Object
    The purpose of this utility it to check if 2 method implementations are equivalent, by comparing the bytecode. This essentual for node sharing where java semantics are involved.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean compareBytecode​(java.lang.String b1, java.lang.String b2)
      Compares 2 bytecode listings.
      boolean equivalent​(java.lang.String method1, org.mvel2.asm.ClassReader class1, java.lang.String method2, org.mvel2.asm.ClassReader class2)
      This actually does the comparing.
      static java.lang.String getMethodBytecode​(java.lang.Class cls, java.lang.String ruleClassName, java.lang.String packageName, java.lang.String methodName, java.lang.String resource)  
      static java.lang.String getMethodBytecode​(java.lang.String methodName, byte[] bytes)
      This will return a series of bytecode instructions which can be used to compare one method with another.
      java.lang.String getMethodBytecode​(java.lang.String methodName, org.mvel2.asm.ClassReader classReader)
      This will return a series of bytecode instructions which can be used to compare one method with another.
      • Methods inherited from class java.lang.Object

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

      • MethodComparator

        public MethodComparator()
    • Method Detail

      • equivalent

        public boolean equivalent​(java.lang.String method1,
                                  org.mvel2.asm.ClassReader class1,
                                  java.lang.String method2,
                                  org.mvel2.asm.ClassReader class2)
        This actually does the comparing. Class1 and Class2 are class reader instances to the respective classes. method1 and method2 are looked up on the respective classes and their contents compared. This is a convenience method.
      • getMethodBytecode

        public java.lang.String getMethodBytecode​(java.lang.String methodName,
                                                  org.mvel2.asm.ClassReader classReader)
        This will return a series of bytecode instructions which can be used to compare one method with another. debug info like local var declarations and line numbers are ignored, so the focus is on the content.
      • getMethodBytecode

        public static java.lang.String getMethodBytecode​(java.lang.String methodName,
                                                         byte[] bytes)
        This will return a series of bytecode instructions which can be used to compare one method with another. debug info like local var declarations and line numbers are ignored, so the focus is on the content.
      • compareBytecode

        public static boolean compareBytecode​(java.lang.String b1,
                                              java.lang.String b2)
        Compares 2 bytecode listings. Returns true if they are identical.
      • getMethodBytecode

        public static java.lang.String getMethodBytecode​(java.lang.Class cls,
                                                         java.lang.String ruleClassName,
                                                         java.lang.String packageName,
                                                         java.lang.String methodName,
                                                         java.lang.String resource)