-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_10-rc"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP
A DESCRIPTION OF THE PROBLEM :
This section:
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#229267
Contains this example:
class Top {
int x;
class Dummy {
Dummy(Object o) {}
}
class Inside extends Dummy {
Inside() {
super(new Object() { int r = x; }); // error
}
Inside(final int y) {
super(new Object() { int r = y; }); // correct
}
}
}
Notice the "//error" comment. But javac *does* compile this without any error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to compile the above program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The compiler should emit an error, as hinted in JLS
ACTUAL -
No error - it compiles successfully.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Top {
int x;
class Dummy {
Dummy(Object o) {}
}
class Inside extends Dummy {
Inside() {
super(new Object() { int r = x; }); // error
}
Inside(final int y) {
super(new Object() { int r = y; }); // correct
}
}
}
---------- END SOURCE ----------
java version "1.6.0_10-rc"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP
A DESCRIPTION OF THE PROBLEM :
This section:
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#229267
Contains this example:
class Top {
int x;
class Dummy {
Dummy(Object o) {}
}
class Inside extends Dummy {
Inside() {
super(new Object() { int r = x; }); // error
}
Inside(final int y) {
super(new Object() { int r = y; }); // correct
}
}
}
Notice the "//error" comment. But javac *does* compile this without any error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to compile the above program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The compiler should emit an error, as hinted in JLS
ACTUAL -
No error - it compiles successfully.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Top {
int x;
class Dummy {
Dummy(Object o) {}
}
class Inside extends Dummy {
Inside() {
super(new Object() { int r = x; }); // error
}
Inside(final int y) {
super(new Object() { int r = y; }); // correct
}
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6770427 Javac allows access to fields not in scope from Anonymous class
- Closed