-
Bug
-
Resolution: Duplicate
-
P2
-
9
After JDK-8026049, ByteBuffer.getFloat() throw BufferOverflowException while BufferUnderflowException is expected.
Test to reproduce this issue:
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
public class Test {
public static void main(String[] args) {
int length = 4;
float value = Float.MIN_VALUE;
ByteBuffer buffer = ByteBuffer.allocate(length);
buffer.putFloat(value);
buffer.position(0);
if (value != buffer.getFloat()) {
System.out.println("Test Fail: Returned value not equal to what was entered.");
} else {
try {
value = buffer.getFloat();
} catch (BufferUnderflowException e) {
System.out.println("Test Pass: Expected Exception " + e.toString() + " thrown.");
} catch (BufferOverflowException e) {
System.out.println("Test Fail: Unexpected Exception " + e.toString() + " thrown.");
e.printStackTrace();
}
}
}
}
Expected result:
Test Pass: Expected Exception java.nio.BufferUnderflowException thrown.
Real result (with build afterJDK-8026049)
Test Fail: Unexpected Exception java.nio.BufferOverflowException thrown.
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:527)
at java.nio.HeapByteBuffer.getFloat(HeapByteBuffer.java:480)
at Test.main(Test.java:18)
Test to reproduce this issue:
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
public class Test {
public static void main(String[] args) {
int length = 4;
float value = Float.MIN_VALUE;
ByteBuffer buffer = ByteBuffer.allocate(length);
buffer.putFloat(value);
buffer.position(0);
if (value != buffer.getFloat()) {
System.out.println("Test Fail: Returned value not equal to what was entered.");
} else {
try {
value = buffer.getFloat();
} catch (BufferUnderflowException e) {
System.out.println("Test Pass: Expected Exception " + e.toString() + " thrown.");
} catch (BufferOverflowException e) {
System.out.println("Test Fail: Unexpected Exception " + e.toString() + " thrown.");
e.printStackTrace();
}
}
}
}
Expected result:
Test Pass: Expected Exception java.nio.BufferUnderflowException thrown.
Real result (with build after
Test Fail: Unexpected Exception java.nio.BufferOverflowException thrown.
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:527)
at java.nio.HeapByteBuffer.getFloat(HeapByteBuffer.java:480)
at Test.main(Test.java:18)
- duplicates
-
JDK-8079459 JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
- Closed
- relates to
-
JDK-8079459 JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
- Closed
-
JDK-8026049 (bf) Intrinsify ByteBuffer.put{Int,Double,Float,...} methods
- Resolved