-
Sub-task
-
Resolution: Delivered
-
P4
-
9
-
Verified
Javac was not in sync with [JLS 8 §15.12.1](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.12.1), specifically:
If the form is TypeName . super . [TypeArguments] Identifier, then:
...
- Otherwise, TypeName denotes the interface to be searched, I.
Let T be the type declaration immediately enclosing the method invocation. It
is a compile-time error if I is not a direct superinterface of T, or if there exists some other direct superclass or direct superinterface of T, J, such that J is a subtype of I.
So javac was not issuing a compiler error for cases like:
```
interface I {
default int f(){return 0;}
}
class J implements I {}
class T extends J implements I {
public int f() {
return I.super.f();
}
}
```
The compiler had some checks for method invocations of the form:
`TypeName . super . [TypeArguments] Identifier`
but there was one issue. If `TypeName` is an interface `I` and `T` is the type declaration immediately enclosing the method invocation, the compiler must issue a compile-time error if there exists some other direct superclass or superinterface of `T`, let's call it `J` such that `J` is a subtype of `I`, as in the example above.
If the form is TypeName . super . [TypeArguments] Identifier, then:
...
- Otherwise, TypeName denotes the interface to be searched, I.
Let T be the type declaration immediately enclosing the method invocation. It
is a compile-time error if I is not a direct superinterface of T, or if there exists some other direct superclass or direct superinterface of T, J, such that J is a subtype of I.
So javac was not issuing a compiler error for cases like:
```
interface I {
default int f(){return 0;}
}
class J implements I {}
class T extends J implements I {
public int f() {
return I.super.f();
}
}
```
The compiler had some checks for method invocations of the form:
`TypeName . super . [TypeArguments] Identifier`
but there was one issue. If `TypeName` is an interface `I` and `T` is the type declaration immediately enclosing the method invocation, the compiler must issue a compile-time error if there exists some other direct superclass or superinterface of `T`, let's call it `J` such that `J` is a subtype of `I`, as in the example above.