@@ -327,13 +327,13 @@ private static void twistCertReqMsg(
327327 // Slice the buffer such that it contains the entire
328328 // handshake message (less the handshake header).
329329 int bufPos = tlsRecord .position ();
330- ByteBuffer buf = tlsRecord . slice (bufPos , msgLen );
330+ ByteBuffer buf = slice (tlsRecord , bufPos , msgLen );
331331
332332 // Replace the signature scheme with an unknown value
333333 twistSigSchemesCertReq (buf , (short ) 0x0000 );
334334 byte [] bufBytes = new byte [buf .limit ()];
335335 buf .get (bufBytes );
336- tlsRecord .put (bufPos , bufBytes );
336+ tlsRecord .position (bufPos ). put ( bufBytes );
337337
338338 break ;
339339 } else {
@@ -345,6 +345,18 @@ private static void twistCertReqMsg(
345345 tlsRecord .reset ();
346346 }
347347
348+ /* Implementation of ByteBuffer.slice(int, int) for JDK11 */
349+ private static final ByteBuffer slice (ByteBuffer buffer , int index , int length ) {
350+ final int limit = buffer .limit ();
351+ final int position = buffer .position ();
352+ buffer .position (index );
353+ buffer .limit (index + length );
354+ ByteBuffer slice = buffer .slice ();
355+ buffer .limit (limit );
356+ buffer .position (position );
357+ return slice ;
358+ }
359+
348360 /**
349361 * Replace the signature schemes in CertificateRequest message with an
350362 * alternative value. It is assumed that the provided ByteBuffer has its
0 commit comments