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

Xueming Shen xueming.shen at oracle.com
Mon Dec 4 23:59:52 UTC 2017


+1

On 12/3/17, 11:53 AM, Claes Redestad 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