RFR: 8176188: jdk/internal/misc/JavaLangAccess/NewUnsafeString.java failing since 9-b93

Paul Sandoz paul.sandoz at oracle.com
Mon Dec 4 20:38:08 UTC 2017


+1

Paul.

> On 3 Dec 2017, at 11:53, Claes Redestad <claes.redestad at oracle.com> wrote:
> 
> Hi,
> 
> the compact strings JEP changed semantics of the package-private String(char[], boolean)
> constructor to do the same as the public String(char[]) constructor.
> 
> Previously the former was used in trusted, internal code to avoid copying the given char[],
> but since the char[] now has to be converted to a byte[] that optimization is no longer
> possible via this method[1], and tests that checked that the returned string shared the
> given char[] naturally stopped working.
> 
> To fix this bug I propose the following clean-up:
> - change all uses of JavaLangAccess.newUnsafeString(char[]) to new String(char[])
> - remove the package-private String(char[], boolean) constructor
> - remove the newUnsafeString from JavaLangAccess
> - remove the now unnecessary NewUnsafeString test
> 
> Patch: http://cr.openjdk.java.net/~redestad/8176188/open.00/
> Bug: https://bugs.openjdk.java.net/browse/JDK-8176188
> 
> Thanks!
> 
> /Claes
> 
> [1] For some of the usages here we could improve somewhat by exposingthe String(byte[], byte)
> constructor, but I think that's out of scope here and I think we'd best avoid leaking the
> coder byte implementation detail outside of java.lang.



More information about the core-libs-dev mailing list