Error: Non-static method overrides static method

Mark Wielaard mark@klomp.org
Mon Jun 28 22:07:00 GMT 2004


Hi,
On Mon, 2004年06月28日 at 23:43, Chris Gray wrote:
> Sometimes I'm glad I only have to deal with bytecode. :0 Out of curiosity, 
> what means "evaluates `expr' for side effects"? Is
> instanceOfFoo.instanceMethod().staticMethod()
> somehow different to 
> instanceOfFoo.instanceMethod(); Foo.staticMethod();
> or is there some other magic involved?

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.
jikes 1.21 has warnings for this kind of use.
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/20040628/e651ee61/attachment.sig>


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /