Current Status

Hans Erik Martino Hansen martino@daimi.au.dk
Wed Feb 17 11:38:00 GMT 1999


On Wed, Feb 17, 1999 at 09:31:40AM -0500, Jeff Sturm wrote:
> Per Bothner wrote:
> > > methods inlined,
> > 
> > No.  It is very limited you can do in terms in inlining of reasonable
> > Java code without violating the access specifiers and hence producing
> > invalid bytecode.  It doesn't seem worth it to me.  Better to inline
> > when compiling to native code, either using gjc or a JIT (i.e.
> > *after* verification).
> 
> You can't inline across class boundaries to be sure... but private
> methods are normally safe to inline.  They are common enough to be a
> worthwhile optimization.

It is only when compiling to .class files you cannot inline across
class boundaries. Example

class A {
  void f() { do this and do that; }
}

class B {
  void f() { A a = new A(); a.f(); }
}                             

When calling a.f() we know exactly what f is being called, it cannot
be overrided by subclassing A. And in contrary to compiling to .class
files A cannot be recompiled either. No dynamic linking here. So we
can just as well inline it.
 
> -- 
> Jeff Sturm
> jsturm@sigma6.com

/erik
-- 
 \|/ ____ \|/  Erik M. Hansen <martino@daimi.aau.dk>
 "@'/ oo \`@"  http://www.daimi.aau.dk/~martino/
 /_| \__/ |_\  Fuglesangsalle 69, DK-8210 Århus V, Denmark. 
    \__U_/     Phone office (+45) 8942 3217, Phone home 86106814


More information about the Java mailing list