2 Replies Latest reply on Dec 17, 2011 6:11 PM by chicken_bones

    Method Content Comparison

    chicken_bones

      I am trying to make a compatibility class loader.

       

      General scenario. People edit the source file, change the contents of a few methods and add a few fields and then recompile the class.

      I then compare the original class and the changed class with javassist.

       

      I need to detect when the methods haven't been changed. I can get the two CtMethods and I tried measuring the length of the code attribute (basemethod.getMethodInfo().getCodeAttribute().getCode() != other) but that fails when the change is a single field access redirection for example. I also tried comparing the contents of the arrays but that didn't work as various bytes at seemingly coordinated locations in the attribute have different values. Due to the fact I don't actually understand how to read the bytecode I'm unable to work out a solution.

       

      If someone could help point me in the right direction or give me a sample of code that could analyse this for me that would be great.

       

      Thankyou for your time.