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: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

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]