I don't recommend obtaining new String objects by calling the
constructor unless you have specific requirements, such as decode a
byte array with a char set, which is the most frequent use case: new
String(Files.readAllBytes(path), StandardCharsets.UTF_8)
Strings from java files like "abc" are
Thanks. That makes sense.
Speaking of Valhalla, how is that coming along? Should I start reading about it
now, or would it be better to wait?
Alan
> On Dec 24, 2021, at 8:29 AM, Brian Goetz wrote:
>
> As the language currently stands, new means new; it is guaranteed to create a
> new
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
class SyncDemo1 {
static volatile int count;
public static void add() {
synchronized (Demo.getString1()) {
System.out.println("count1 : " + (count++));
}
}
}
class
As the language currently stands, new means new; it is guaranteed to create a
new identity. (When Valhalla comes along, instances of certain classes will be
identity-free, so the meaning of new will change somewhat, but String seems
likely to stay as it is.)
The language is allowed (in some
Just when I thought the answer was simple, now it seems more complex.
Are you saying that new would always create a new object but the GC might merge
multiple instances of String into a single instance?
Also, if new String() always creates a new instance, then it seems that this
statement
On Thu, 23 Dec 2021 16:42:50 GMT, Alan Bateman wrote:
>> Masanori Yano has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> 8272746: ZipFile can't open big file (NegativeArraySizeException)
>
>
> Could you please review the JDK-8272746 bug fixes?
> Since the array index is of type int, the overflow occurs when the value of
> end.cenlen is too large because of too many entries.
> It is necessary to read a part of the CEN from the file to fix the problem
> fundamentally, but the way will