Correct. Alexey 2001 Honda CBR600F4i (CCS) 1992 Kawasaki EX500 http://azinger.blogspot.com http://bsheet.sourceforge.net http://wcollage.sourceforge.net
________________________________ From: Marcelo Fukushima <takesh...@gmail.com> To: javaposse@googlegroups.com Sent: Wednesday, August 26, 2009 2:34:32 PM Subject: Re: Optimizations? was Re: [The Java Posse] A quick and dirty way to throw unchecked exceptions im guessing its because of the "receiving" side of the append function? have not tried, but id hope that "two " + "three " + one() would become "two three " + one() ? On Wed, Aug 26, 2009 at 2:54 PM, Alexey Zinger<inline_f...@yahoo.com> wrote: > There are quite a few optimizations with strings, for sure. Such as > replacing concatenation using "+" operator with StringBuilder and > concatenation of literals with a single literal (*). > > There's an interesting exception to that rule. The following will work as > expected: > "one " + "two " + "three" > gets turned into > "one two three" > > However, in the context of this: public String getOne() { return "one "; } > this: getOne() + "two " + "three" > will not get turned into > getOne() + "two three" > > Sorry if this was off-topic. > > Alexey > 2001 Honda CBR600F4i (CCS) > 1992 Kawasaki EX500 > http://azinger.blogspot.com > http://bsheet.sourceforge.net > http://wcollage.sourceforge.net > > > ________________________________ > From: Marcelo Fukushima <takesh...@gmail.com> > To: javaposse@googlegroups.com > Sent: Wednesday, August 26, 2009 1:32:28 PM > Subject: Re: Optimizations? was Re: [The Java Posse] A quick and dirty way > to throw unchecked exceptions > > > i guess nowadays javac translates almost literally the source code > into bytecode, leaving the hard work for JIT > > On Wed, Aug 26, 2009 at 7:29 AM, Christian > Catchpole<christ...@catchpole.net> wrote: >> >> of course it's need a return if it's NOT being JITted... im talking a >> load of crap tonight.. aload_0 f crap.. get it! :) >> >> On Aug 26, 8:09 pm, Christian Catchpole <christ...@catchpole.net> >> wrote: >>> yeah, don't take too much notice of that. i noticed that if you >>> disassemble a "throw", it doesn't have a return. but the a=a does. >>> maybe its requirement of bytecode that a method that does return, >>> finishes with return byte code. but its like Java strings being a >>> char array with a size. there's no need to terminate it. it cant run >>> off the end. >>> >>> On Aug 26, 7:53 pm, Fabrizio Giudici <fabrizio.giud...@tidalwave.it> >>> wrote: >>> >>> >>> >>> > Christian Catchpole wrote: >>> > > Compile this.. (any package you like, or no package at all) >>> >>> > > public class Rethrow { >>> > > public static void unchecked(Throwable t) { >>> > > t=t; >>> > > } >>> > > } >>> >>> > > javap reports the byte code as.. >>> >>> > > public static void unchecked(java.lang.Throwable); >>> > > Code: >>> > > Stack=1, Locals=1, Args_size=1 >>> > > 0: aload_0 >>> > > 1: astore_0 >>> > > 2: return >>> >>> > I'm surprised - I expected that the compiler would optimize out the >>> > useless operation and only output the return... >>> >>> > -- >>> > Fabrizio Giudici - Java Architect, Project Manager >>> > Tidalwave s.a.s. - "We make Java work. Everywhere." >>> > weblogs.java.net/blog/fabriziogiudici-www.tidalwave.it/blog >>> > fabrizio.giud...@tidalwave.it - mobile: +39 348.150.6941 >> > >> > > > > -- > http://mapsdev.blogspot.com/ > Marcelo Takeshi Fukushima > > > > > -- http://mapsdev.blogspot.com/ Marcelo Takeshi Fukushima --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to javaposse@googlegroups.com To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---