和的区别

From a practical point to most people, <? extends Object> is the same as <?>, like everyone have suggested here.html

However, they differ in two very minor and subtle points:java

  1. The JVMS (Java Virtual Machine Specification) has a special specification for the unbounded wildcards, as ClassFileFormat-Java5 specifies that unbounded wildcard gets encoded as *, while encodes a Object-bounded wildcard as +Ljava/lang/Object;.  Such change would leak through any library that analyzes the bytecode.  Compiler writers would need to deal with this issue too.  From revisions to "The class File Format"jvm

  2. From reifiablity standpoint, those are different.  JLS 4.6 and 4.7 codify List<?> as a reifiable type, but List<? extends Object> as a erasured type.  Any library writer adding .isReifiable() (e.g. mjc lib) needs to account for that, to adhere to the JLS terminology.  From JLS 4.6 and 4.7.this


这个解释超牛逼,先把它记下来。它来自于http://stackoverflow.com/questions/2016017/unbounded-wildcards-in-java/2016382#2016382编码

update:spa

如下是我翻译的,求指点。翻译

从使用它的角度来看,<? extends Object>和<?>是同样的,就像每一个人所建议的。
尽管如此,他们有两个细微的区别:
1,JVMS 对无界通配符有个特定的规范,ClassFileFormat-Java5的规范是,无界通配符将被编码成*,而以Object为上界的通配符(? extends Object)将被编码成+Ljava/lang/Object。这个区别在类库分析字节码时会带来一个漏洞。编译器编写者将不得不处理这个问题;可参照 revisions to "The class File Format"。
2,从可信赖的角度看,它们是不一样的。JLS4.6和4.7认为 List<?>是一个可信赖的类型,可是List<? extends Object>是会被擦除掉的类型。任何库的编写者在考虑这个问题时须要使用.isReifiable(),以拥护JLS所倡导的思想。code