Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

References to static fields in enum initializers

Thread view: 
Christopher Benson-Manica - 05 Jul 2007 16:09 GMT
Consider this simple enumerated type:

class Foo {
 foo, bar;

 Foo() {
   if( equals(foo) ) {
     // ...
   }
 }
}

javac rightfully points out the illegal access to foo in the
initializer for the enumerated type.  However, javac 1.6.0_01
cheerfully accepts

class Foo {
 foo, bar;

 Foo() {
   switch(this) {
     case foo:
       break;
   }
 }
}

, which of course is broken and fails at runtime.  My question: is
javac right to accept this code (meaning that the language definition
might need some work), or should I file a bug report?

Signature

C. Benson Manica           | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com      | don't, I need to know.  Flames welcome.

Christopher Benson-Manica - 05 Jul 2007 19:41 GMT
> Consider this simple enumerated type:

> class Foo {

Canny observers will notice that Foo is not an enum.  Obviously I
meant enum Foo.  Apologies.

Signature

C. Benson Manica           | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com      | don't, I need to know.  Flames welcome.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.