-
Bug
-
Resolution: Not an Issue
-
P2
-
9
Let's consider following code:
interface I {}
class Test {
void foo() {
new Object() {
I bar() {
return (I)this;
}
};
}
}
This code compiles successfully by javac from JDK build 128. However compilation should fail on 'return (I)this;' because the anonymous class doesn't have any relation to interface I.
interface I {}
class Test {
void foo() {
new Object() {
I bar() {
return (I)this;
}
};
}
}
This code compiles successfully by javac from JDK build 128. However compilation should fail on 'return (I)this;' because the anonymous class doesn't have any relation to interface I.
- relates to
-
JDK-8161009 15.9.5: Anonymous classes aren't actually 'final'
- Closed
-
JDK-8161013 Never treat anonymous classes as 'final'
- Closed