我相信这与Java
8兼容性指南中提到的更改有关
从此版本开始,参数和方法注释将复制到合成桥方法。此修复程序意味着现在对于以下程序:
@Target(value = {ElementType.PARAMETER})@Retention(RetentionPolicy.RUNTIME) @interface ParamAnnotation {} @Target(value = {ElementType.METHOD})@Retention(RetentionPolicy.RUNTIME) @interface MethodAnnotation {} abstract class T<A,B> { B m(A a){ return null; } } class CovariantReturnType extends T<Integer, Integer> { @MethodAnnotation Integer m(@ParamAnnotation Integer i) { return i; } public class VisibilityChange extends CovariantReturnType {} }每个生成的桥方法将具有其重定向到的方法的所有注释。参数注释也将被复制。行为的这种变化可能会影响某些注释处理器,或者通常会影响使用注释的任何应用程序。
第二个返回an
I而不是an
IE的方法是生成的合成方法,因为您覆盖的方法中的返回类型比父类中的返回类型窄。请注意,如果您没有缩小的返回类型,则它不在声明的方法列表中。所以我认为这不是错误,而是有意的更改。



