ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephane Bailliez <stephane.baill...@haht.com>
Subject RE: cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdef s Exit.java Filter.java FixCRLF.java GenerateKey.java Get.java Jar.java
Date Thu, 11 Apr 2002 15:00:06 GMT
> -----Original Message-----
> From: Magesh Umasankar [mailto:umagesh@apache.org]

> > 2) the static strings will be concatenated at compile time 
> as there is no
> > variables here. check the bytecode with javap
> >
> 
> oh!  Something new to learn everyday -
> thanks for clarifying - forget my earlier
> comments, Stefan ;-)

Actually the string concatenation might be 'slightly' different depending on
the version of the java compiler and its version but this is what happens so
far it might depend 'where' is the variable in the concatenation to
completely break the compiler 'optimization'. (which is close to absolute
zero now since JDK 1.2 anyway)

from the top of my head you may have something like this:

"aaa" + "bbb" -> "aaabbb"
"aaa" + "bbb" + z  -> new StringBuffer("aaabbb").append(z).toString()
"aaa" + "bbb" + z + "ccc" -> new
StringBuffer("aaa").append("bbb").append(z).append("ccc").toString()

I also remember that in some cases one compiler may use the empty
StringBuffer ctor instead of the String one.
Your mileage may vary.


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message