Why does Java 8 apply annotations differently to derived classes?

前端 未结 1 987
离开以前
离开以前 2021-01-02 06:03

If I have the following two classes:

// Base.java
public abstract class Base {
  abstract void method(T t);
}

and

         


        
1条回答
  •  囚心锁ツ
    2021-01-02 06:25

    That's because it was fixed as this behavior seems to be more consistent. See the JDK-6695379 issue for details. And that's not only Java 8, it was also backported to Java 7u80:

    C:\Test>"C:\Program Files\Java\jdk1.7.0_79\bin\javac.exe" Derived.java
    
    C:\Test>javap -v Derived.class >javac7_79
    
    C:\Test>"C:\Program Files\Java\jdk1.7.0_80\bin\javac.exe" Derived.java
    
    C:\Test>javap -v Derived.class >javac7_80
    
    C:\Test>diff javac7_79 javac7_80
    2,3c2,3
    <   Last modified 18.05.2015; size 484 bytes
    <   MD5 checksum bd5e729c8eda30f72f3dc5301fa9bfc2
    ---
    >   Last modified 18.05.2015; size 496 bytes
    >   MD5 checksum 728d9e30b9aab2381e711b3edd008000
    69a70,71
    >     RuntimeVisibleAnnotations:
    >       0: #14()
    

    0 讨论(0)
提交回复
热议问题