Hi, Thanks for all your comments. I think this answers my question.
BTW, I am aware of http://wiki.eclipse.org/Evolving_Java-based_APIs - this is actually the starting point of our work. It turns out that some of the inlining rules used by the compiler are rather surprising (see below), and I thought that sometimes wrapper types are used like "@donotinline" compiler annotations. But obviously this is not the case here. public static final int = 42; -> will be inlined public static final int = 40+2; -> will be inlined (constant folding) public static final String = "42"; -> will be inlined public static final String = "4"+"2"; -> will be inlined (constant folding) public static final Integer = 42; -> will NOT be inlined !! Cheers, Jens PS: here are some examples illustrating this if somebody is interested in more details: https://bitbucket.org/jensdietrich/java-library-evolution-puzzlers On 19/10/2013, at 5:23 AM, Matt Benson <gudnabr...@gmail.com> wrote: > +1; the NumberUtils constants were added by Stephen Colebourne back in 2002 > and as such far predated the #valueOf() methods introduced on the primitive > wrapper classes in Java 5, so were really a similar caching mechanism for > values one might expect to be commonly used. Stephen might have more to > add here. I'd have to be fed individual cases but anyone can use viewvc > annotations to do the research I just did. > > Matt > > > On Fri, Oct 18, 2013 at 10:07 AM, sebb <seb...@gmail.com> wrote: > >> On 18 October 2013 15:49, Benedikt Ritter <brit...@apache.org> wrote: >>> Hello Jens, >>> >>> welcome to the ML. It is good style to prefix emails with the short name >> of >>> the component they are about. So since you have a question about commons >>> lang you should put the [LANG] prefix in the subject line (I've done it >> in >>> this response). >>> >>> Now to your question: TBH I don't really know :-) Can anybody else help? >>> Hen? Matt? >> >> AFAIK, these are just commonly used constant values which are not >> provided by the standard Java classes. >> >> This avoids the overhead of boxing for code that needs Long rather than >> long. >> >>> If your looking for material about binary compatibility, you should read >>> http://wiki.eclipse.org/Evolving_Java-based_APIs It provides a good >>> overview over the topic. >>> >>> Regards, >>> Benedikt >>> >>> >>> 2013/10/15 Jens Dietrich <j.b.dietr...@massey.ac.nz> >>> >>>> Hi, >>>> >>>> I have a quick question regarding the use of constants in Apache >> Commons - >>>> in some classes/interfaces like org.apache.commons.lang.math.NumberUtils >>>> some constants are defined using wrapper types and not primitive types. >>>> What are the reasons for this? >>>> >>>> The background of my question is that I am doing some research on binary >>>> vs source compatibility in Java. One such issue is constant inlining, >> and I >>>> try to find out whether engineers consciously use wrapper types to >> prevent >>>> inlining. >>>> >>>> Cheers, Jens >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org >>>> For additional commands, e-mail: dev-h...@commons.apache.org >>>> >>>> >>> >>> >>> -- >>> http://people.apache.org/~britter/ >>> http://www.systemoutprintln.de/ >>> http://twitter.com/BenediktRitter >>> http://github.com/britter >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org >> For additional commands, e-mail: dev-h...@commons.apache.org >> >>