Error: Non-static method overrides static method

Tom Tromey tromey@redhat.com
Mon Jun 28 21:56:00 GMT 2004


Chris> Sometimes I'm glad I only have to deal with bytecode. :0 Out of
Chris> curiosity, what means "evaluates `expr' for side effects"? Is
Chris>     instanceOfFoo.instanceMethod().staticMethod()
Chris> somehow different to 
Chris>   instanceOfFoo.instanceMethod(); Foo.staticMethod();
Chris> or is there some other magic involved?

There's no real difference.  One minor detail is that you can't
always make the source transformation from:

    expr.staticMethod();

to:

   expr;
   Klass.staticMethod();

... since not all expressions are valid as statements.

Other than that, if the expression can't have a side effect, the
compiler is free to just drop it afaik.  There are a couple instances
of this construct in Classpath, but my impression is that they are
usually mistakes where the intent was something else.

Tom



More information about the Java mailing list