Skip to content

Fix documentation errors in Java.Nio, Java.Nio.Channels, Java.Nio.Charset and Java.Nio.FileNio (R094, pass 3) - #1973

Merged
jonathanpeppers merged 3 commits into
mainfrom
jonathanpeppers-review-java-nio-docs-r094-pass-3
Nov 28, 2026
Merged

jonathanpeppers merged 3 commits into
mainfrom
jonathanpeppers-review-java-nio-docs-r094-pass-3

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: a54471d6eec944baa6b9d8dee238f3c3eb599e7d

Dimension Assessment Rationale
Change confidence 9/10 ↑ Each edit is one line and is proven by a pinned libcore or dotnet/android@9bc18c75 source line.
↑ Transfer wording matches the merged #1941 (Object) and #1972 (Throwable) fixes.
↑ Changed XML parses; git diff --check is clean; no new placeholders.
↑ gemini-4-argon rubber-duck review and Copilot review of a54471d6 found no issues.
↓ OpenPublishing.Build and the dalexsoto review are pending.

Scope

Pass-3 review item R094: 164 files in Java.Nio, Java.Nio.Channels, Java.Nio.Channels.Spi, Java.Nio.Charset, Java.Nio.Charset.Spi, Java.Nio.FileNio, Java.Nio.FileNio.Attributes and Java.Nio.FileNio.Spi. Only text that AI changed (git diff 86f7744a1 origin/main) is in scope: 2032 channels in 760 Docs blocks. Every channel was checked against a numeric pinned source line. 526 channels are JniPeerMembers, ThresholdClass, ThresholdType and UnregisterFromRuntime boilerplate (kickoff deferred list); they were checked against the generated code and are correct.

Sources: Android SDK sources 37.2 (libcore ojluni java/nio/**) and dotnet/android 9bc18c75 (Mono.Android Java.Lang/Object.cs, Java.Lang/Throwable.cs, Android.Runtime/JNIEnv.cs, Java.Nio/*.cs, metadata, map.csv, and the Java.Interop generator).

Fixes

  1. Java.Nio.FileNio.Files.NewDirectoryStream(IPath, IDirectoryStreamFilter) summary: "iterate over all entries in the directory" → "iterate over the entries in the directory". The filter overload returns only the entries that the filter accepts (Files.java lines 543-560). "All entries" is the text of the unfiltered overload (lines 438-440). The block was changed by AI, so this summary is fixed under rule 8f.
  2. Java.Nio.FileNio.FileSystem.RootDirectories remarks: removed the AI-added sentence "There is no guarantee that a root directory can be accessed." It is not in the pinned FileSystem.getRootDirectories Javadoc (FileSystem.java lines 168-190).
  3. The transfer parameter of 37 (IntPtr, JniHandleOwnership) constructors said "Specifies whether ownership of the JNI reference transfers to this instance." That is wrong: the peer always makes its own reference.
    • 11 Java.Lang.Object-derived types now say "Specifies how the runtime handles the JNI reference, including its release and peer registration." (Object.cs lines 110-118, JNIEnv.cs lines 360-393).
    • 26 Java.Lang.Throwable-derived types now say "Specifies how the runtime releases the incoming JNI reference after the instance copies it." (Throwable.cs lines 99-110).

Checked and kept

  • Java.Nio.Buffer.GetDirectBufferAddress returns: "or its memory region is unavailable" is correct. Buffer.cs lines 11-12 return JNIEnv.GetDirectBufferAddress(Handle) unchanged for a direct buffer, build-tools/jnienv-gen/Generator.g.cs lines 2049-2056 bind it as a direct JNI call, and the JNI GetDirectBufferAddress contract returns NULL when the memory region is undefined. An earlier commit removed these words; a54471d6 restores them.

Uncertain findings

None.

Follow-ups (out of scope, not AI-changed)

  • Files.NewBufferedWriter(IPath, IOpenOption[]) and Files.Write(IPath, IIterable, IOpenOption[]) link to the wrong Charset overloads.

Checks

  • Changed XML files parse; encoding and line endings are unchanged.
  • git diff --check is clean; no new To be added placeholders.
  • Rubber-duck review with gemini-4-argon on a54471d6: no issues.
  • Copilot review on a54471d6: approval recommended, no comments.

- Files.NewDirectoryStream(IPath, IDirectoryStreamFilter): the filter
  overload iterates over the entries the filter accepts, not all entries
  (Files.java newDirectoryStream(Path, Filter) Javadoc).
- FileSystem.RootDirectories: remove an AI-added sentence that is not in
  the pinned FileSystem.getRootDirectories Javadoc or the Android reference.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 10:40
@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) November 28, 2026 10:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the two API documentation corrections.

No open issues 🎉

What changed in this PR

This documentation-only PR corrects two Java.Nio.FileNio API descriptions as part of the R094 pass-3 review, aligning them with the pinned Android sources.

Changes:

  • Corrects the filtered NewDirectoryStream summary so it no longer promises all directory entries.
  • Removes a RootDirectories access statement absent from the pinned Android documentation.
File Description
docs/​xml/​Java.Nio.FileNio/​FileSystem.xml Removes the extra root-directory access statement.
docs/​xml/​Java.Nio.FileNio/​Files.xml Corrects the filtered directory-stream summary.

Review effort: Balanced

….Nio (R094)

The transfer parameter on 37 handle constructors said that ownership of the JNI reference transfers to the instance. Object.cs:110-118 and JNIEnv.cs:360-393 (Object) and Throwable.cs:99-110 (Throwable) show that the peer copies the reference and transfer only selects release and registration.

Buffer.GetDirectBufferAddress said it returns IntPtr.Zero when the memory region is unavailable; Buffer.cs:10-14 returns IntPtr.Zero only when the buffer is not direct.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the documentation-only Java NIO reference clarifications.

No open issues 🎉

Review effort: Balanced

@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

The JNI GetDirectBufferAddress contract returns NULL when the memory
region is undefined, and Buffer.cs passes that result through.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the NIO documentation changes.

No open issues 🎉

Review effort: Balanced

@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto

Copy link
Copy Markdown
Member

In response to @jonathanpeppers's request: The 37 constructor parameter edits agree with Object.SetHandle, Throwable.SetHandle and JNIEnv reference handling at dotnet/android 9bc18c75acd8945015e14e460f067a75f32ec20f; I found no blocker in the 38-file diff. One source check remains: I verified the Files.newDirectoryStream filter-overload summary and FileSystem.getRootDirectories paragraph against libcore de876a01b29230b877c9f408348c38a90ee724a5, but have not established their correspondence to the Android SDK sources 37.2 cited here (Files.java lines 438-440/543-560 and FileSystem.java lines 168-190). No fetch failed; the SDK-to-revision mapping remains unverified. This is a reviewer coverage gap, not a defect identified in the PR. The review remains queued for that specific check.

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the 38 documentation files, including JNI transfer semantics against the managed runtime and the NIO directory contracts against upstream sources. The constructor wording matches the actual Object/Throwable inheritance paths, and the directory-stream correction matches the filtered overload. No blocking issues found.

@jonathanpeppers
jonathanpeppers merged commit 4f9f4f9 into main Nov 28, 2026
4 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-review-java-nio-docs-r094-pass-3 branch November 28, 2026 11:41
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.

3 participants