On 10/18/15 10:45 AM, joe darcy wrote:
On 10/17/2015 10:10 AM, Andrew Haley wrote:
On 10/17/2015 05:46 PM, Stuart Marks wrote:
(I view calling an "inherited" class static method to be poor coding style, but
neither javac nor NetBeans warns about it.)
That surely can be fixed. Should we start a feature request?
I believe
javac -Xlint:static ...
does the check of interest; from running javac -X
static Warn about accessing a static member using an instance
Nope, it doesn't, I was surprised too.
class A {
static void foo() {
System.out.println("A.foo()");
}
}
class B extends A {
}
B.foo(); // no warning
A a = new A();
a.foo(); // warning
B b = new B();
b.foo(); // warning
I've filed
https://bugs.openjdk.java.net/browse/JDK-8139827
I checked NetBeans but I only looked briefly at the hints and style options, and
nothing I enabled generated a warning. But it would probably be worth it for
someone to take another look. It would also be helpful if somebody could check
this with other IDEs as well.
s'marks