This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Error: Non-static method overrides static method


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

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]