[8u] RFR 8254631: Better support ALPN byte wire values in SunJSSE
Martin Balao
mbalao at redhat.com
Tue May 18 16:06:04 UTC 2021
Hi Severin,
Thanks for having a look at this.
On 4/26/21 8:39 AM, Severin Gehwolf wrote:
>> * AlpnGreaseTest.java uses a java.util.Arrays public API not available
>> in 8u (introduced by JDK-8033148 [2]).
>> * Fixed creating copies of the arrays to compare.
>
> 89 System.arraycopy(bytes, i, a1, 0, greaseBytes.length);
> 90 System.arraycopy(greaseBytes, 0, a2, 0, greaseBytes.length);
> 91 if (Arrays.equals(a1, a2)) {
>
> I don't think we'd need to copy greaseBytes for this array comparison,
> do we? Can't we use 'Arrays.equals(a1, greaseBytes)'?
>
> Better yet, don't do a copy at all and just do a simple search using a
> ByteBuffer like this:
> https://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8254631.test-fix.patch
Yes, I didn't put much thinking into this but you are right: performance
can be improved. In that regard, looks to me that wrapping with a
ByteBuffer may not be necessary when we consider the precondition that,
inside the outer loop [1], 'bytes' array will be equal or greater than
'grease' array.
Please have a look at this proposal:
*
http://cr.openjdk.java.net/~mbalao/webrevs/8254631/8254631.webrev.jdk8u.jdk.01/
Kind regards,
Martin.-
--
[1] - 86 for (int i = 0; i < bytes.length - greaseBytes.length;
i++) {
More information about the jdk8u-dev
mailing list