-
Bug
-
Resolution: Fixed
-
P4
-
19
-
b10
Quoting from:
https://mail.openjdk.java.net/pipermail/compiler-dev/2022-April/019517.html
public class Demo {
public static void main(String[] args) {
var obj = new Object() {
static void foo() {
System.out.println("Static method of anonymous class");
}
};
obj.foo(); // Cannot replace instance qualifier with class reference
}
}
With -Xlint:static, javac reports the following warning:
Demo.java:8: warning: [static] static method should be qualified by
type name, <anonymous Demo$1>, instead of by an expression
obj.foo(); // Cannot replace instance qualifier with class reference
^
1 warning
https://mail.openjdk.java.net/pipermail/compiler-dev/2022-April/019517.html
public class Demo {
public static void main(String[] args) {
var obj = new Object() {
static void foo() {
System.out.println("Static method of anonymous class");
}
};
obj.foo(); // Cannot replace instance qualifier with class reference
}
}
With -Xlint:static, javac reports the following warning:
Demo.java:8: warning: [static] static method should be qualified by
type name, <anonymous Demo$1>, instead of by an expression
obj.foo(); // Cannot replace instance qualifier with class reference
^
1 warning