J2SE5.0 Enumの謎

昨日、ふと気づいたんだけれども、JSRに書いてあるEnumerationと、Eclipse上で書いたときで、違いがある。


The enum class has the following fields generated automatically:

/**
* An immutable list containing the values comprising this enum class
* in the order they're declared. This field may be used to iterate
* over the constants as follows:
*
* for(className c : className.VALUES)
* System.out.println(c);
*/
public static List VALUES;

/**
* Returns an immutable list containing the values comprising this enum
* class in the order they're declared. This instance method simply
* returns VALUES. Few programmers should have any need to use this
* method. It is provided for use by sophisticated enum-based data
* structures to prevent the need for reflective access to
* VALUES.
*
* @return an immutable list containing the values comprising this enum
* class, in the order they're declared.
*/
public final List family();

ということなので、enumの取りうる値を全て取得したい場合、enum.VALUESで、List<enum>が返ってくるのはずだけれど、Eclipse上で動くコードを書いたら、以下のように。


Random random = new Random();
ElementEnum e = ElementEnum.values()[random.nextInt(ElementEnum
.values().length)];

つまり、enum.values()で、enum[]が返ってきている。


要するに、JSRに書いてあるようなコードを実行するには


for(className c : className.values())
System.out.println(c);

と書かなければ動かない。


うーん。どっちが正しいんだ?JSRが正しいと考えた方がいいんだろうけど、Eclipse上であまりに自然に動くしなあ。
でも、family()は、動かなかったし。
そもそも、EclipseでもVMは、1.5.0_01を指定してるからなあ。Eclipseがっていうより、VMとしてOKって事だよな。謎だ。