diff --git a/liquidjava-example/src/main/java/testSuite/classes/bytebuf_correct/ByteBufTest.java b/liquidjava-example/src/main/java/testSuite/classes/bytebuf_correct/ByteBufTest.java
new file mode 100644
index 000000000..7124c64d9
--- /dev/null
+++ b/liquidjava-example/src/main/java/testSuite/classes/bytebuf_correct/ByteBufTest.java
@@ -0,0 +1,23 @@
+package testSuite.classes.bytebuf_correct;
+
+// SO 48582520 — UnsupportedOperationException at ByteBuffer.array()
+// https://stackoverflow.com/questions/48582520
+// SO class is already self-contained pure java.nio; only added the package.
+import java.nio.ByteBuffer;
+
+public class ByteBufTest {
+
+ public static final int TEST_BUFFER_SIZE = 128;
+
+ // private ByteBuffer mDirectBuffer;
+
+ public ByteBufTest() {
+ // FIX (from accepted answer): mDirectBuffer = ByteBuffer.wrap(new byte[TEST_BUFFER_SIZE]);
+ // or guard with: if (mDirectBuffer.hasArray()) { ... }
+ ByteBuffer mDirectBuffer = ByteBuffer.wrap(new byte[TEST_BUFFER_SIZE]);
+ // VIOLATION: a direct buffer is not array-backed -> array() throws
+ // UnsupportedOperationException.
+ byte[] buf = mDirectBuffer.array();
+ buf[1] = 100;
+ }
+}
diff --git a/liquidjava-example/src/main/java/testSuite/classes/bytebuf_correct/ByteBufferRefinements.java b/liquidjava-example/src/main/java/testSuite/classes/bytebuf_correct/ByteBufferRefinements.java
new file mode 100644
index 000000000..e18e7deec
--- /dev/null
+++ b/liquidjava-example/src/main/java/testSuite/classes/bytebuf_correct/ByteBufferRefinements.java
@@ -0,0 +1,41 @@
+package testSuite.classes.bytebuf_correct;
+
+import liquidjava.specification.ExternalRefinementsFor;
+import liquidjava.specification.Ghost;
+import liquidjava.specification.Refinement;
+import liquidjava.specification.RefinementAlias;
+import liquidjava.specification.StateRefinement;
+import liquidjava.specification.StateSet;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.CharBuffer;
+import java.nio.ShortBuffer;
+import java.nio.IntBuffer;
+import java.nio.LongBuffer;
+import java.nio.FloatBuffer;
+import java.nio.DoubleBuffer;
+
+
+@Ghost("boolean arrayBacked")
+@ExternalRefinementsFor("java.nio.ByteBuffer")
+public interface ByteBufferRefinements {
+
+ // ---- Backing array access ----
+
+ @StateRefinement(to="_ ? arrayBacked() : !arrayBacked()")
+ boolean hasArray();
+
+ @StateRefinement(from="arrayBacked()")
+ byte[] array();
+
+ @StateRefinement(from="arrayBacked()")
+ int arrayOffset();
+
+ @Refinement("arrayBacked(_)")
+ ByteBuffer wrap(byte[] array, int offset, int length);
+
+ @Refinement("arrayBacked(_)")
+ ByteBuffer wrap(byte[] array);
+
+ }
diff --git a/liquidjava-example/src/main/java/testSuite/classes/bytebuf_error/ByteBufTest.java b/liquidjava-example/src/main/java/testSuite/classes/bytebuf_error/ByteBufTest.java
new file mode 100644
index 000000000..b547f7940
--- /dev/null
+++ b/liquidjava-example/src/main/java/testSuite/classes/bytebuf_error/ByteBufTest.java
@@ -0,0 +1,41 @@
+package testSuite.classes.bytebuf_error;
+
+// SO 48582520 — UnsupportedOperationException at ByteBuffer.array()
+// https://stackoverflow.com/questions/48582520
+// SO class is already self-contained pure java.nio; only added the package.
+import java.nio.ByteBuffer;
+
+public class ByteBufTest {
+
+ public static final int TEST_BUFFER_SIZE = 128;
+
+ // private ByteBuffer mDirectBuffer;
+
+ public ByteBufTest() {
+ // FIX (from accepted answer): mDirectBuffer = ByteBuffer.wrap(new byte[TEST_BUFFER_SIZE]);
+ // or guard with: if (mDirectBuffer.hasArray()) { ... }
+ ByteBuffer mDirectBuffer = ByteBuffer.allocateDirect(TEST_BUFFER_SIZE);
+ // VIOLATION: a direct buffer is not array-backed -> array() throws
+ // UnsupportedOperationException.
+ byte[] buf = mDirectBuffer.array(); // State Refinement Error
+ buf[1] = 100;
+ }
+
+ public void test(ByteBuffer mDirectBuffer) {
+ printBuffer("nativeInitDirectBuffer", mDirectBuffer.array()); // State Refinement Error
+ }
+
+ private void printBuffer(String tag, byte[] buffer) {
+ StringBuffer sBuffer = new StringBuffer();
+ for (int i = 0; i < buffer.length; i++) {
+ sBuffer.append(buffer[i]);
+ sBuffer.append(" ");
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ ByteBufTest item = new ByteBufTest();
+ ByteBuffer mDirectBuffer = ByteBuffer.allocateDirect(128);
+ item.test(mDirectBuffer);
+ }
+}
diff --git a/liquidjava-example/src/main/java/testSuite/classes/bytebuf_error/ByteBufferRefinements.java b/liquidjava-example/src/main/java/testSuite/classes/bytebuf_error/ByteBufferRefinements.java
new file mode 100644
index 000000000..c3e056024
--- /dev/null
+++ b/liquidjava-example/src/main/java/testSuite/classes/bytebuf_error/ByteBufferRefinements.java
@@ -0,0 +1,41 @@
+package testSuite.classes.bytebuf_error;
+
+import liquidjava.specification.ExternalRefinementsFor;
+import liquidjava.specification.Ghost;
+import liquidjava.specification.Refinement;
+import liquidjava.specification.RefinementAlias;
+import liquidjava.specification.StateRefinement;
+import liquidjava.specification.StateSet;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.CharBuffer;
+import java.nio.ShortBuffer;
+import java.nio.IntBuffer;
+import java.nio.LongBuffer;
+import java.nio.FloatBuffer;
+import java.nio.DoubleBuffer;
+
+
+@Ghost("boolean arrayBacked")
+@ExternalRefinementsFor("java.nio.ByteBuffer")
+public interface ByteBufferRefinements {
+
+ // ---- Backing array access ----
+
+ @StateRefinement(to="_ ? arrayBacked() : !arrayBacked()")
+ boolean hasArray();
+
+ @StateRefinement(from="arrayBacked()")
+ byte[] array();
+
+ @StateRefinement(from="arrayBacked()")
+ int arrayOffset();
+
+ @Refinement("arrayBacked(_)")
+ ByteBuffer wrap(byte[] array, int offset, int length);
+
+ @Refinement("arrayBacked(_)")
+ ByteBuffer wrap(byte[] array);
+
+ }
diff --git a/liquidjava-example/src/main/java/testSuite/classes/iterator_queue_error/IteratorRefinements.java b/liquidjava-example/src/main/java/testSuite/classes/iterator_queue_error/IteratorRefinements.java
new file mode 100644
index 000000000..3af73c39f
--- /dev/null
+++ b/liquidjava-example/src/main/java/testSuite/classes/iterator_queue_error/IteratorRefinements.java
@@ -0,0 +1,28 @@
+package testSuite.classes.iterator_queue_error;
+
+import liquidjava.specification.ExternalRefinementsFor;
+import liquidjava.specification.Refinement;
+import liquidjava.specification.StateRefinement;
+import liquidjava.specification.StateSet;
+
+/**
+ * Observer-style iteration over {@link java.util.Scanner} (an iterator-shaped JDK class):
+ * {@code hasNext} is an informative check (no state change), and {@code next} consumes one
+ * element, resetting state so a fresh check is required before the next consumption.
+ *
+ *
{@code java.util.Iterator} itself is an interface, and external refinements only attach to
+ * classes — Scanner gives us the same API in a class form.
+ */
+@StateSet({"hasMore", "inNext", "notInNext"})
+@ExternalRefinementsFor("java.util.Iterator")
+public interface IteratorRefinements {
+
+ @StateRefinement(to = "_ --> hasMore()")
+ boolean hasNext();
+
+ @StateRefinement(from = "hasMore()", to = "inNext()")
+ N next();
+
+ @StateRefinement(from="inNext()", to="notInNext()")
+ void remove();
+}
diff --git a/liquidjava-example/src/main/java/testSuite/classes/iterator_queue_error/IteratorRemoveBeforeNext.java b/liquidjava-example/src/main/java/testSuite/classes/iterator_queue_error/IteratorRemoveBeforeNext.java
new file mode 100644
index 000000000..c16c52e2c
--- /dev/null
+++ b/liquidjava-example/src/main/java/testSuite/classes/iterator_queue_error/IteratorRemoveBeforeNext.java
@@ -0,0 +1,64 @@
+package testSuite.classes.iterator_queue_error;
+
+// SO 22361194 — "Iterator.remove() IllegalStateException"
+// https://stackoverflow.com/questions/22361194
+// Faithful to the question body. The asker's own (unshown) types are given
+// minimal stand-ins so the original structure compiles:
+// - the queues qev1/qev2/qcv1/qcv2 -> a small Queue exposing enqueue()/iterator()
+// - CInteger -> the nested class below
+// The asker catches UnsupportedOperationException, but iterator().remove()
+// before next() actually throws IllegalStateException — so the catch does NOT
+// fire. That mismatch is reproduced verbatim from the post.
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+
+public class IteratorRemoveBeforeNext {
+
+ static class Queue implements Iterable {
+ private final ArrayList items = new ArrayList<>();
+ void enqueue(T item) { items.add(item); }
+ public Iterator iterator() { return items.iterator(); }
+ }
+
+ static class CInteger {
+ final int value;
+ CInteger(int value) { this.value = value; }
+ }
+
+ public static void main(String[] args) {
+ Queue