On Tuesday 30 May 2006 23:38, Alex Blewitt wrote: > On 30/05/06, Chris Gray <[EMAIL PROTECTED]> wrote: > > If the implementation is an empty method and is final, a straightforward > > static flow analysis will show that the evaluation of the arguments can > > also be optimised away. > > Not necessarily. Evaluation of arguments may have side-effects, and > therefore even if the call to the logging gets optimised away, the > evaluation may not be.
You're right, and the more I look at it the less likely it seems to me that the evaluation of parameters will be optimised away. To start with string concatenation: the expression ("hello " + "world") has no side-effects, but the optimiser has to perform an escape analysis in order to recognise that new StringBuffer("hello ").append("world")has none. (StringBuilder I guess these days). And in ("Frobbing the " + foo), if (as is likely) the type of foo is a non-final class or interface, all bets are off; a subclass could override the toString() method to have all kind of side-effects. Logging ("Connecting to " + remotehost.getHostName()) certainly has side-effects. It's probably also not a good idea to rely too much on JIT optimisations, given that Harmony should run on a number of VMs and not all of these will have a fully optimising JIT in all circumstances. It should be possible to compile the class libraries with or without logging. Chris -- Chris Gray /k/ Embedded Java Solutions BE0503765045 Embedded & Mobile Java, OSGi http://www.k-embedded-java.com/ [EMAIL PROTECTED] +32 3 216 0369 --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]