Re: a quick question about String

2022-01-03 Thread Andrew Haley
On 12/30/21 16:12, Alexander Scherbatiy wrote: Would it be useful to have some kind of an immutable array in Java language which works in the same way as ordinary array except it is not to possible to change its values after creation? Yes. https://openjdk.java.net/jeps/8261007 -- Andrew Haley

Re: a quick question about String

2022-01-01 Thread Kim Barrett
> On Dec 24, 2021, at 2:46 PM, [email protected] wrote: > >> Are you saying that new would always create a new object but the GC might >> merge multiple instances of String into a single instance? > > About jvm's string optimizations, jvm may make different string > objects with the same c

Re: a quick question about String

2022-01-01 Thread Raffaello Giulietti
Hello, the simple answer is that new String(...) == new String(...) *never* evaluates to true )it might throw, though), whatever constructors you are using and whatever arguments you pass to to them. Some garbage collectors *might* de-duplicate the underlying arrays (but you cannot te

Re: a quick question about String

2021-12-30 Thread Alexander Scherbatiy
[email protected]> Subject: Re: a quick question about String new String() always creates a new instance. Gruss Bernd -- http://bernd.eckenfels.net Von: core-libs-dev im Auftrag von Alan Snyder Gesendet: Thursday, December 23, 2021 6:59:18 PM An:

Re: a quick question about String

2021-12-24 Thread -
st partly why the > > >> constructors on soon-to-be value objects are deprecated; they become > > >> meaningless. The other is that if the presumption is that we should > > >> always intern new Strings, I must disagree. Pooling takes time and > > mem

Re: a quick question about String

2021-12-24 Thread Alan Snyder
cide if this is appropriate >>> in their situation. Of course, the GC system seems to be capable of >>> stepping in in some incarnations, which adds something of a counterexample, >>> but that is, if I recall, configurable. >>> >>> >>> On Thu, Dec 23,

Re: a quick question about String

2021-12-24 Thread Xeno Amess
in their situation. Of course, the GC system seems to be capable of > >> stepping in in some incarnations, which adds something of a > counterexample, > >> but that is, if I recall, configurable. > >> > >> > >> On Thu, Dec 23, 2021 at 2:53 PM Xe

Re: a quick question about String

2021-12-24 Thread Brian Goetz
, which adds something of a counterexample, >> but that is, if I recall, configurable. >> >> >> On Thu, Dec 23, 2021 at 2:53 PM Xeno Amess wrote: >> >>> never should,as Object can be use as lock. >>> >>> XenoAmess >>> ___

Re: a quick question about String

2021-12-24 Thread Alan Snyder
use as lock. >> >> XenoAmess >> >> From: core-libs-dev on behalf of >> Bernd Eckenfels >> Sent: Friday, December 24, 2021 5:51:55 AM >> To: alan Snyder ; core-libs-dev < >> [email protected]

Re: a quick question about String

2021-12-23 Thread Enrico Olivelli
enfels.net > > ________ > > Von: core-libs-dev im Auftrag von > > Alan Snyder > > Gesendet: Thursday, December 23, 2021 6:59:18 PM > > An: core-libs-dev > > Betreff: a quick question about String > > > > Do the public constructors of String actually do what their documentation > > says (allocate a new instance), or is there some kind of compiler magic > > that might avoid allocation? > > > > > > -- > Simon Roberts > (303) 249 3613

Re: a quick question about String

2021-12-23 Thread Simon Roberts
f of > Bernd Eckenfels > Sent: Friday, December 24, 2021 5:51:55 AM > To: alan Snyder ; core-libs-dev < > [email protected]> > Subject: Re: a quick question about String > > new String() always creates a new instance. > > Gruss > Bernd > -- > http:/

Re: a quick question about String

2021-12-23 Thread Xeno Amess
never should,as Object can be use as lock. XenoAmess From: core-libs-dev on behalf of Bernd Eckenfels Sent: Friday, December 24, 2021 5:51:55 AM To: alan Snyder ; core-libs-dev Subject: Re: a quick question about String new String() always creates a new

Re: a quick question about String

2021-12-23 Thread Bernd Eckenfels
new String() always creates a new instance. Gruss Bernd -- http://bernd.eckenfels.net Von: core-libs-dev im Auftrag von Alan Snyder Gesendet: Thursday, December 23, 2021 6:59:18 PM An: core-libs-dev Betreff: a quick question about String Do the public

a quick question about String

2021-12-23 Thread Alan Snyder
Do the public constructors of String actually do what their documentation says (allocate a new instance), or is there some kind of compiler magic that might avoid allocation?