Skip to content

test(jni): characterize DataSource open preconditions and count precision - #9636

Open
jackylee-ch wants to merge 1 commit into
vortex-data:developfrom
jackylee-ch:jni-datasource-contract-tests
Open

test(jni): characterize DataSource open preconditions and count precision#9636
jackylee-ch wants to merge 1 commit into
vortex-data:developfrom
jackylee-ch:jni-datasource-contract-tests

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

DataSource.open guards the JNI boundary with eight argument checks, and none of their messages was
asserted anywhere. Dropping one does not surface as an IllegalArgumentException: a null name or a
negative length crosses into native code instead. RowCount and ByteSize were only ever exercised
in their Exact form, so Unknown silently returning a value would let a caller read a non-empty
file as zero rows.

Test only, one new file. Each check is asserted by message, and the positive case opens a real file
so a future tightening cannot over-reject.

Verified non-vacuous: nine mutations of DataSource.java — neutralising each of the seven
Java-reachable checks, and making each Unknown.asOptional() return a value — each fail exactly the
test that claims to pin them, and the source reverts clean. :vortex-jni:test goes 72 → 84; the one
failure in both runs is a pre-existing local one (TestMinimal.testSelectionIndicesMustBeSortedAndUnique,
stale local dylib), not from this change. spotlessCheck and javadoc pass.

The eighth check, invalid data source pointer, is only reachable if native returns 0, so it is not
covered here.

AI assistance

Written with agentic AI assistance. Per the AI-generated-tests rule I confirmed these assertions
fail when the behaviour they describe is removed, rather than only that they pass.

…sion

The eight argument checks in DataSource.open guard the JNI boundary: each
runs before the native call, so losing one does not raise
IllegalArgumentException but sends a null or a negative length into native
code. None of their messages was asserted anywhere in the test tree.

RowCount and ByteSize are two precision ladders over the same three cases,
and only Exact was covered. An Unknown that returned a value instead of an
empty OptionalLong would let a caller read a non-empty file as zero rows.

Asserts each check by message so a refactor that keeps the check but
reclassifies the failure is still caught, and opens a real file for the
positive case.

Signed-off-by: jackylee <qcsd2011@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant