On Thu, 22 Dec 2005 14:31:20 +0100, "Ingo R. Homann"
<ihomann_spam@web.de> wrote, quoted or indirectly quoted someone who
said :
>So, what is the problem about this?
The problem was not realising that the inner classes for each enum
class EXTENDED the enum main class. If they didn't, how enums worked
would be quite mysterious.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Chris Smith - 22 Dec 2005 15:52 GMT
> The problem was not realising that the inner classes for each enum
> class EXTENDED the enum main class. If they didn't, how enums worked
> would be quite mysterious.
This is, in any case, the obvious implementation. I'd be careful about
making an assertion about the LANGUAGE that this happens. It is
certainly true in the Sun reference implementation, and will probably be
true of any other implementation you happen to be working with, as well.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Ingo R. Homann - 23 Dec 2005 11:19 GMT
Hi,
>>The problem was not realising that the inner classes for each enum
>>class EXTENDED the enum main class. If they didn't, how enums worked
>>would be quite mysterious.
>
> This is, in any case, the obvious implementation. I'd be careful about
> making an assertion about the LANGUAGE that this happens....
IIRC, this behaviour is specified in the langspec.
I do not remember if the kind of implementation as *sub*class is
specified as well - that means i do not remember if
"Breed.DALMATIAN.getClass() != Breed.getClass()" is true - which should
be true if it is a *sub*class. But of course "Breed.DALMATIAN instanceof
Breed" must be true.
But independant of the welldefined behaviour: I cannot see any reason
(performance?) to implement enums not as subclasses...
Ciao,
Ingo
Chris Smith - 23 Dec 2005 14:40 GMT
> IIRC, this behaviour is specified in the langspec.
Yes, you're right. I should start reading the JLS more. Section 8.9
says:
"The optional class body of an enum constant implicitly defines an
anonymous class declaration (15.9.5) that extends the immediately
enclosing enum type."

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation