諸々

土曜日から気管にくる風邪を患ってしまい、気管支炎でおとなしくしてます。

Genericsについてまとめたエントリでも書こうかなと思ってJavaの入門書をいくつか流し読みしてみたのですが、なんかGenericsをみんないっせいにスルーしてますね…。やっぱり敬遠されてるのでしょうか。
そういう入門書とか、雑誌で特集組んでたやつがあれば教えてください。

あと、ブコメで無限型についてちょっと触れられていたので、その部分をJava言語仕様第3版から抜粋。このセクションの終わりのほうです。

It is possible that the process above yields an infinite type. This is permissible, and Java compilers must recognize such situations and represent them appropriately using cyclic data structures.

                                                      • -

Discussion
The possibility of an infinite type stems from the recursive calls to lub().
Readers familiar with recursive types should note that an infinite type is not the same as a recursive type.

15.12.2.7 Inferring Type Arguments Based on Actual Arguments

で、

<T extends Number & Comparable<? extends T>>

を無限型と呼ぶかどうかはちょっと不明です。Tはあくまで型変数で、その右側はただの型境界なので。

この前のエントリでは、

lub(Integer, Long) as R = Number & Comparable<? extends R>

というようなRを無限型と呼んでおり、そのエミュレーションに先ほどの型境界つきの型変数を利用していた感じです。こっちは、Rそのものの定義にRが出現しちゃいます。