6593946: (bf) X-Buffer.compact() does not discard mark as specified
Summary: InvalidMarkException now correctly thrown. Thanks to keiths@redhat.com for the bug report and initial fix.
Reviewed-by: sherman, darcy
diff --git a/test/java/nio/Buffer/BasicInt.java b/test/java/nio/Buffer/BasicInt.java
index 4a58871..d5e9e15 100644
--- a/test/java/nio/Buffer/BasicInt.java
+++ b/test/java/nio/Buffer/BasicInt.java
@@ -31,6 +31,7 @@
// -- This file was mechanically generated: Do not edit! -- //
import java.nio.*;
+import java.lang.reflect.Method;
public class BasicInt
@@ -283,13 +284,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
private static void tryCatch(Buffer b, Class ex, Runnable thunk) {
boolean caught = false;
try {
thunk.run();
} catch (Throwable x) {
- if (ex.isAssignableFrom(x.getClass()))
+ if (ex.isAssignableFrom(x.getClass())) {
caught = true;
+ } else {
+ fail(x.getMessage() + " not expected");
+ }
}
if (!caught)
fail(ex.getName() + " not thrown", b);
@@ -356,7 +385,6 @@
// Exceptions
- boolean caught = false;
relPut(b);
b.limit(b.capacity() / 2);
b.position(b.limit());
@@ -386,6 +414,14 @@
b.put(b.limit(), (int)42);
}});
+ tryCatch(b, InvalidMarkException.class, new Runnable() {
+ public void run() {
+ b.position(0);
+ b.mark();
+ b.compact();
+ b.reset();
+ }});
+
// Values
b.clear();