Repository navigation
JExtract: report every skipped declaration; add failOnSkippedDeclarations - #3
Open
piercifani wants to merge 2 commits into
Open
piercifani wants to merge 2 commits into
piercifani wants to merge 2 commits into
Conversation
This was referenced Nov 3, 2026
piercifani
force-pushed
the
jni/03-skipped-declarations
branch
from
November 3, 2026 14:41
ab27944 to
0b84bb1
Compare
piercifani
force-pushed
the
jni/03-skipped-declarations
branch
from
November 3, 2026 15:19
0b84bb1 to
697c497
Compare
piercifani
force-pushed
the
jni/03-skipped-declarations
branch
from
November 3, 2026 15:56
697c497 to
10d1d97
Compare
…rations Declarations that analysis accepted but JNI translation could not handle were dropped with a debug-level log line only, so missing bindings went unnoticed (for example `[T?]` and `[[K: V]]` return types). Even `"logLevel": "debug"` in swift-java.config didn't show them, because the CLI's default `--log-level` always overwrote the config's value. - Log JNI translation failures as warnings, in the same form as analysis skips. - Cache failed translations: assigning nil to the cache dictionary removed the key, so every failure was re-translated (and re-reported) on each pass. - Add `failOnSkippedDeclarations`: after generating, jextract fails and lists every declaration skipped during analysis or JNI translation. The list is part of the error, since the tool exits through fatalError and log lines on a piped stdout aren't flushed. - Only override the config's `logLevel` when `--log-level` is passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With failOnSkippedDeclarations, the sample's bindings must cover every public declaration: jextract fails instead of silently dropping one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
piercifani
force-pushed
the
jni/03-skipped-declarations
branch
from
November 3, 2026 16:46
10d1d97 to
62fe3de
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack 3/21 · base:
jni/02-closures-jextracted-types· previous: #2 · next: #5Problem
jextract drops declarations it can't translate, and in JNI mode most drops were invisible:
[T?]or[[K: V]], for example, just doesn't appear in the Java output, with nothing in the build log."logLevel": "debug"inswift-java.configdidn't help: the CLI's default--log-level(info) always overwrote the config's value.[ExtractedFunc: TranslatedFunctionDecl], and storingnilremoves the key, so each failure was re-translated on every printing pass.For a project bridging thousands of declarations, nobody can tell what was lost without diffing the generated Java against the Swift API.
Changes
Failed to translate: 'Collections.sparse()' in module 'M'; <reason>.updateValue(nil, forKey:), with an optional value type), so each is reported once.failOnSkippedDeclarations(defaultfalse). After generating, jextract fails if anything was skipped during analysis or JNI translation, and the error lists every declaration with its reason. The list is in the error itself because the tool exits throughfatalError, and log lines written to a piped stdout (as under the SwiftPM plugin) are lost at that point.--log-levelonly overrides the config'slogLevelwhen it's passed explicitly.makeSwiftJavaAnalyzertakes an optional diagnostics sink; analysis skips are collected through the existingSwiftExtractDiagnosticsSink.SwiftJavaConfigFile.md(generate-config-docs --checkpasses).Example with
failOnSkippedDeclarations: true:Why Skip needs it
Skip's own bridge fails the build on anything it can't bridge, so moving a module onto jextract has to keep that guarantee. In a test suite of small Skip-shaped modules, some drops produced no log line at all, even with
logLevelset todebug.Noise check
The JNI sample now prints 4 distinct new warnings, each a real drop:
Data.init(bytes:count:)andData.withUnsafeBytes(_:)(unsafe pointers),GenericEnumWithValue.someandMyID.rawValue(genericT).Kotlin in this PR
The Kotlin sample turns on
failOnSkippedDeclarationsin both modules'swift-java.config. From this PR up, its build fails if jextract drops any public declaration, so every Kotlin test in the stack runs against complete bindings. Checked by adding an unsupported-> [Item?]function, which fails the build with it listed.Testing
./gradlew :Samples:SwiftJavaExtractJNIKotlinSampleApp:testpasses at this point in the stack.JNISkippedDeclarationsTests: a translation failure is recorded once after both the Java and Swift passes, analysis skips reach the sink, andfailIfSkippedthrows only when configured, with the list in the message.swift test --disable-experimental-prebuilts --disable-sandboxpasses../gradlew :Samples:SwiftJavaExtractJNISampleApp:testpasses 275/275."logLevel": "debug"in the config, debug output now appears; before, only the unconditional[debug][swift-java]prints did.swift format lint --stricton changed files;git diff --check.Not in this PR
FFMSwift2JavaGenerator+JavaTranslation.swift; left as is.🤖 Generated with Claude Code