Error: Non-static method overrides static method
Mark Wielaard
mark@klomp.org
Tue Jun 29 01:04:00 GMT 2004
Hi,
On Mon, 2004年06月28日 at 23:56, Mark Wielaard wrote:
> The first will throw a NullPointerException when
> instanceOfFoo.instanceMethod() evaluates to null.
>> Also the instance can be a subclass (SubFoo) of the class (Foo) that
> currently has the static method. The first expression will call the
> staticMethod() of SubFoo when it is later added. The second will always
> call the static method of the class Foo.
Bah. I seem to be wrong on both counts. Sorry.
> jikes 1.21 has warnings for this kind of use.
Which I should have read more carefully:
7. t.main(new String[0]);
^----^
*** Semantic Warning: Invoking the class method "main" via an instance
is discouraged because the method invoked will be the one in the
variable's declared type, not the instance's dynamic type.
So it is precisely the other way around from what I said above.
Cheers,
Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java/attachments/20040629/edac62ef/attachment.sig>
More information about the Java
mailing list