both|both methods have same erasure, yet neither overrides the other
这段代码会报一个编译错误,both methods have same erasure, yet neither overrides the other。
这个错误的意思是,两个方法在类型擦除后,具有相同的原生类型参数列表,但是也不能覆盖另一个方法。
泛型类型在编译后,会做类型擦除,只剩下原生类型。如参数列表中的T类型会编译成Object,但是会有一个Signature。
尽管两个getValue方法具有相同的字节码,但是类型参数信息用 一个新的签名(signature) 属性记录在类模式中。JVM 在装载类时记录这个签名信息,并在运行时通过反射使它可用。
【both|both methods have same erasure, yet neither overrides the other】这就导致了这个方法既不能作为覆盖父类getValue方法的方法,也不能作为getValue方法的重载。
推荐阅读
- Mockito|Mockito mock void methods Example
- WARN|WARN [launcher]: PhantomJS have not captured in 60000 ms, killing
- 句型-have|句型-have something done
- protobuf实例运行proto: cannot use m.ProtoMethods() (type *protoreflect.Message) as type *struct ...解决方案
- “keep|“keep fit”、“have fun”——少儿体适能教案读书笔记
- keras报错Error when checking target: expected dense_1 to have shape (5,) but got array with shape (1,)
- Three|Three Passions I have Lived For
- ValueError: Error when checking input: expected input_image_meta to have shape (None, 14) but got ar
- ValueError: Error when checking : expected input_1 to have 4 dimensions, but got array with shape
- Day|Day 10, P103-113