Skip to content

Commit 2ca55b8

Browse files
authored
JDK 8 compatibility fix for vector datatype handling (#2750)
1 parent e1acc9e commit 2ca55b8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/VectorUtils.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package com.microsoft.sqlserver.jdbc;
66

7+
import java.nio.Buffer;
78
import java.nio.ByteBuffer;
89
import java.nio.ByteOrder;
910
import java.text.MessageFormat;
@@ -56,7 +57,12 @@ static Vector fromBytes(byte[] bytes) {
5657

5758
ByteBuffer buffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN);
5859

59-
buffer.position(getHeaderLength()); // Skip the first 8 bytes (header)
60+
/*
61+
* The cast is required for JDK 8 compatibility.
62+
* JDK 8 calls method Buffer.position(I)LBuffer,
63+
* while in JDK 9+ calls method ByteBuffer.position(I)LByteBuffer
64+
*/
65+
((Buffer) buffer).position(getHeaderLength()); // Skip the first 8 bytes (header)
6066

6167
for (int i = 0; i < objectCount; i++) {
6268
objectArray[i] = buffer.getFloat();

0 commit comments

Comments
 (0)