Class MethodComparator

java.lang.Object
org.drools.mvel.asm.MethodComparator

public class MethodComparator extends 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.
  • Constructor Details

    • MethodComparator

      public MethodComparator()
  • Method Details

    • equivalent

      public boolean equivalent(String method1, org.mvel2.asm.ClassReader class1, 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 String getMethodBytecode(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 String getMethodBytecode(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(String b1, String b2)
      Compares 2 bytecode listings. Returns true if they are identical.
    • getMethodBytecode

      public static String getMethodBytecode(Class cls, String ruleClassName, String packageName, String methodName, String resource)