なるほどなー、これ実際にはそのままダイレクトには書けないですけど、明示的にキャストしてあげれば書けますね for (String name : (Iterable<String>) request.getHeaderNames()::asIterator) { ... }https://t.co/NTL5iUFzL9
It is a compile-time error if a method reference expression occurs in a program in someplace other than an assignment context (§5.2), an invocation context (§5.3), or a casting context (§5.5).
また、本家がメンテナンスをしなくなったEOL(End of Life)の過去版についても、どこかの誰かがセキュリティアップデート版を作ったのであれば、GPLの波及によりソースコードを公開することになるだろう。リリースサイクルの変更に伴いサポート期間が憂慮される点はあるが、独自にサポートすることを表明している企業もある。こうした際にも、GPLというライセンスは安心感につながる。
Historically, wildcards are a direct descendant of the work by Atsushi Igarashi and Mirko Viroli. Readers interested in a more comprehensive discussion should refer to On Variance-Based Subtyping for Parametric Types by Atsushi Igarashi and Mirko Viroli, in the Proceedings of the 16th European Conference on Object Oriented Programming (ECOOP 2002). This work itself builds upon earlier work by Kresten Thorup and Mads Torgersen (Unifying Genericity, ECOOP 99), as well as a long tradition of work on declaration based variance that goes back to Pierre America's work on POOL (OOPSLA 89).
ArrayCreationExpression:
new PrimitiveType DimExprs [Dims]
new ClassOrInterfaceType DimExprs [Dims]
new PrimitiveType Dims ArrayInitializer
new ClassOrInterfaceType Dims ArrayInitializer
DimExprs:
DimExpr {DimExpr}
DimExpr:
{Annotation} [ Expression ]
ここで、単に new ClassOrInterfaceType DimExprs [Dims] とあるので、パラメタライズドタイプの配列も宣言できそうに見えるが、注釈がついている。
The rules above imply that the element type in an array creation expression cannot be a parameterized type, unless all type arguments to the parameterized type are unbounded wildcards.
An array initializer may be specified in a field declaration (§8.3, §9.3) or local variable declaration (§14.4), or as part of an array creation expression (§15.10.1), to create an array and provide some initial values.
publicclass Main {
publicstaticvoid main(String[] args) {
Hoge hoge = new Hoge();
List<String> list = new ArrayList<String>();
hoge.foo(list); // OK
List<Integer> list2 = new ArrayList<Integer>();
hoge.foo(list2); // NG
}
}
>javap Child.class
Compiled from "Child.java"
public class Child implements Parent {
public Child();
public java.lang.Integer getValue();
public java.lang.Object getValue();
}