Re: a quick question about String

2022-01-01 Thread Kim Barrett
> On Dec 24, 2021, at 2:46 PM, liangchenb...@gmail.com 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

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

Re: Type narrowing security leak

2022-01-01 Thread Raffaello Giulietti
Hi, if I understand correctly, you are supposing that method changeAmount() is part of a security sensitive application under attack. Its implementation first attempts a data validation by invoking isUserIdAllowedOrThrowException(), then transforms validated data in a lossy way (narrowing,