On Tue, 1 Jun 2021 19:28:44 GMT, Valerie Peng <valer...@openjdk.org> wrote:
>> src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java >> line 874: >> >>> 872: } else if (!src.isDirect() && !dst.isDirect()) { >>> 873: // if src is read only, then we need a copy >>> 874: if (!src.isReadOnly()) { >> >> Do you mean if (src.hasArray() && dst.hasArray())? Even if src is not read >> only, but array()/arrayOffset() methods are optional and can only be safely >> invoked after the hasArray() call. > > I assume this is again the case of !isDirect()&&!isReadOnly => hasArray()? hasArray() would not be appropriate here. The code needs to get into this if, being a heap bytebuffer. If I use hasArray() it will skip to the ending else and cause a test failure. Having the isReadOnly checked inside the if(isDirect) causes it to create the necessary copy ------------- PR: https://git.openjdk.java.net/jdk/pull/4072