title: java8 - annotating compareTo <T> of Comparable<T> adds annotations to compareTo(Object o)
body: <p>I have an annotation </p>
  
  <pre><code>package javaannotationtest;
  
  import java.lang.annotation.*;
  
  @Target({ElementType.METHOD})
  @Retention(RetentionPolicy.RUNTIME)
  public @interface CustomAnnotation {
  }
  </code></pre>
  
  <p>This is applied to compareTo in following class</p>
  
  <pre><code>package javaannotationtest;
  
  public class Customer implements Comparable&lt;Customer&gt;{
      @Override
      @CustomAnnotation
      public int compareTo(Customer o) {
          return 0;
      }
  }
  </code></pre>
  
  <p>The class gives different result with java-7 and java-8 compiled code.</p>
  
  <p>Java 7 </p>
  
  <pre><code>1.7.0_45 -&gt; public int javaannotationtest.Customer.compareTo(javaannotationtest.Customer)
   has  annotation of type javaannotationtest.CustomAnnotation
  1.7.0_45 -&gt; public int javaannotationtest.Customer.compareTo(java.lang.Object)
   has no annotation of type javaannotationtest.CustomAnnotation
  </code></pre>
  
  <p><strong>Note that compareTo(Object) does not have the annotation.</strong></p>
  
  <p>Java 8</p>
  
  <pre><code>1.8.0 -&gt; public int javaannotationtest.Customer.compareTo(javaannotationtest.Customer)
   has  annotation of type javaannotationtest.CustomAnnotation
  1.8.0 -&gt; public int javaannotationtest.Customer.compareTo(java.lang.Object)
   has  annotation of type javaannotationtest.CustomAnnotation
  </code></pre>
  
  <p>Java 8 has annotation added to the <code>compareTo(java.lang.Object)</code> method</p>
  
  <p>Here is output from javap   for the version compiled with Java 8 (probably not relevant, it shows the annotation added to both methods)</p>
  
  <pre><code>  Classfile /C:/code/java8annoation/out/production/java8annoation/javaannotationtest/Customer.class
    Last modified 17 Apr, 2014; size 719 bytes
    MD5 checksum 678e0371f5f9ed5666b513c940f365a7
    Compiled from "Customer.java"
  public class javaannotationtest.Customer extends java.lang.Object implements java.lang.Comparable&lt;javaannotationtest.Customer&gt;
    Signature: #20                          // Ljava/lang/Object;Ljava/lang/Comparable&lt;Ljavaannotationtest/Customer;&gt;;
    SourceFile: "Customer.java"
    minor version: 0
    major version: 52
    flags: ACC_PUBLIC, ACC_SUPER
  Constant pool:
     #1 = Methodref          #4.#23         //  java/lang/Object."&lt;init&gt;":()V
     #2 = Class              #24            //  javaannotationtest/Customer
     #3 = Methodref          #2.#25         //  javaannotationtest/Customer.compareTo:(Ljavaannotationtest/Customer;)I
     #4 = Class              #26            //  java/lang/Object
     #5 = Class              #27            //  java/lang/Comparable
     #6 = Utf8               &lt;init&gt;
     #7 = Utf8               ()V
     #8 = Utf8               Code
     #9 = Utf8               LineNumberTable
    #10 = Utf8               LocalVariableTable
    #11 = Utf8               this
    #12 = Utf8               Ljavaannotationtest/Customer;
    #13 = Utf8               compareTo
    #14 = Utf8               (Ljavaannotationtest/Customer;)I
    #15 = Utf8               o
    #16 = Utf8               RuntimeVisibleAnnotations
    #17 = Utf8               Ljavaannotationtest/CustomAnnotation;
    #18 = Utf8               (Ljava/lang/Object;)I
    #19 = Utf8               Signature
    #20 = Utf8               Ljava/lang/Object;Ljava/lang/Comparable&lt;Ljavaannotationtest/Customer;&gt;;
    #21 = Utf8               SourceFile
    #22 = Utf8               Customer.java
    #23 = NameAndType        #6:#7          //  "&lt;init&gt;":()V
    #24 = Utf8               javaannotationtest/Customer
    #25 = NameAndType        #13:#14        //  compareTo:(Ljavaannotationtest/Customer;)I
    #26 = Utf8               java/lang/Object
    #27 = Utf8               java/lang/Comparable
  {
    public javaannotationtest.Customer();
      descriptor: ()V
      flags: ACC_PUBLIC
      Code:
        stack=1, locals=1, args_size=1
           0: aload_0       
           1: invokespecial #1                  // Method java/lang/Object."&lt;init&gt;":()V
           4: return        
        LineNumberTable:
          line 3: 0
        LocalVariableTable:
          Start  Length  Slot  Name   Signature
              0       5     0  this   Ljavaannotationtest/Customer;
  
    public int compareTo(javaannotationtest.Customer);
      descriptor: (Ljavaannotationtest/Customer;)I
      flags: ACC_PUBLIC
      Code:
        stack=1, locals=2, args_size=2
           0: iconst_0      
           1: ireturn       
        LineNumberTable:
          line 7: 0
        LocalVariableTable:
          Start  Length  Slot  Name   Signature
              0       2     0  this   Ljavaannotationtest/Customer;
              0       2     1     o   Ljavaannotationtest/Customer;
      RuntimeVisibleAnnotations:
        0: #17()
  
    public int compareTo(java.lang.Object);
      descriptor: (Ljava/lang/Object;)I
      flags: ACC_PUBLIC, ACC_BRIDGE, ACC_SYNTHETIC
      Code:
        stack=2, locals=2, args_size=2
           0: aload_0       
           1: aload_1       
           2: checkcast     #2                  // class javaannotationtest/Customer
           5: invokevirtual #3                  // Method compareTo:(Ljavaannotationtest/Customer;)I
           8: ireturn       
        LineNumberTable:
          line 3: 0
        LocalVariableTable:
          Start  Length  Slot  Name   Signature
              0       9     0  this   Ljavaannotationtest/Customer;
      RuntimeVisibleAnnotations:
        0: #17()
  }
  </code></pre>
  
  <p>Could someone explain relevant changes in Java 8? (Will offer Bounty when is becomes eligible).</p>