C
Christopher Benson-Manica
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?
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?