Repository navigation
Fix documentation errors in Java.Nio, Java.Nio.Channels, Java.Nio.Charset and Java.Nio.FileNio (R094, pass 3) - #1973
Conversation
- 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>
There was a problem hiding this comment.
🟢 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
NewDirectoryStreamsummary so it no longer promises all directory entries. - Removes a
RootDirectoriesaccess 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>
|
@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>
|
@dalexsoto review |
|
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
left a comment
There was a problem hiding this comment.
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.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
a54471d6eec944baa6b9d8dee238f3c3eb599e7d↑ Transfer wording matches the merged #1941 (Object) and #1972 (Throwable) fixes.
↑ Changed XML parses;
git diff --checkis clean; no new placeholders.↑ gemini-4-argon rubber-duck review and Copilot review of
a54471d6found 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.AttributesandJava.Nio.FileNio.Spi. Only text that AI changed (git diff 86f7744a1 origin/main) is in scope: 2032 channels in 760Docsblocks. 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/android9bc18c75(Mono.AndroidJava.Lang/Object.cs,Java.Lang/Throwable.cs,Android.Runtime/JNIEnv.cs,Java.Nio/*.cs,metadata,map.csv, and the Java.Interop generator).Fixes
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.javalines 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.Java.Nio.FileNio.FileSystem.RootDirectoriesremarks: removed the AI-added sentence "There is no guarantee that a root directory can be accessed." It is not in the pinnedFileSystem.getRootDirectoriesJavadoc (FileSystem.javalines 168-190).transferparameter 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.Java.Lang.Object-derived types now say "Specifies how the runtime handles the JNI reference, including its release and peer registration." (Object.cslines 110-118,JNIEnv.cslines 360-393).Java.Lang.Throwable-derived types now say "Specifies how the runtime releases the incoming JNI reference after the instance copies it." (Throwable.cslines 99-110).Checked and kept
Java.Nio.Buffer.GetDirectBufferAddressreturns: "or its memory region is unavailable" is correct.Buffer.cslines 11-12 returnJNIEnv.GetDirectBufferAddress(Handle)unchanged for a direct buffer,build-tools/jnienv-gen/Generator.g.cslines 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;a54471d6restores them.Uncertain findings
None.
Follow-ups (out of scope, not AI-changed)
Files.NewBufferedWriter(IPath, IOpenOption[])andFiles.Write(IPath, IIterable, IOpenOption[])link to the wrongCharsetoverloads.Checks
git diff --checkis clean; no newTo be addedplaceholders.a54471d6: no issues.a54471d6: approval recommended, no comments.