title: Can I use kryo output on same jvm to do deep compare of instances of exact same class?
body: <p>I have two instances of exact same class which I want to compare. I am already using kryo to serialize and send it to DB. </p>
  
  <p>I was wondering, can I compare both byte[] produced by Kryo (default configuration) and determine if both are same or not?</p>
  
  <p>I did run following code and it seems to be working fine. Need openion from experts. </p>
  
  <pre><code>private static void testKryoCompare() {
  
      //KryoUtil is just a utility wrapper on Kryo. Nothing special there.
  
      int n = 1000_000;
      long start;
  
      for(int i=0;i&lt;n;i++) {
          byte[] b1 = KryoUtil.serialize(job);
          job.setParam1(i+"");
          byte[] b2 = KryoUtil.serialize(job);
          if(Arrays.equals(b1, b2) == true)
              System.out.println("Should not be true: "+job.getParam1());
      }
  
      for(int i=0;i&lt;n;i++) {
          job.setParam1(UUID.randomUUID().toString());
          byte[] b1 = KryoUtil.serialize(job);
          byte[] b2 = KryoUtil.serialize(job);
          if(Arrays.equals(b1, b2)==false)
              System.out.println("Should not be false: "+job.getParam1());
      }
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Both instances are of exact same class - Job.class. No structure of field change. In case if one field is List&lt;> then one instance may have ArrayList and another may have LinkedList. Kryo output may be different in that case. </p>
  
  <p>My usecase is to reduce # of network calls and ripple effect. If some calls slip through even when values are same, it is ok. Based on that I am rephrasing my question below:</p>
  
  <p><strong>Question</strong> : Will there be a scenario where kryo output is same even when values are different in Job.class?</p>