Skip to content

jextract: fail on missing or empty javaPackage (#919) - #921

Open
bhanage-viraj wants to merge 1 commit into
swiftlang:mainfrom
bhanage-viraj:fix-919-empty-java-package
Open

bhanage-viraj wants to merge 1 commit into
swiftlang:mainfrom
bhanage-viraj:fix-919-empty-java-package

Conversation

@bhanage-viraj

Copy link
Copy Markdown

Summary

  • jextract no longer treats a missing/empty javaPackage as success and emit package ;. SwiftToJava.run() now requires a non-empty package before analysis or any generated output, for both JNI and FFM.
  • --java-package stays optional so the value can still come from swift-java.config / the build plugin. Surrounding whitespace is rejected rather than trimmed; empty segments (com..foo) are rejected. The unnamed/default package is not implemented.
  • Config docs now state that jextract requires a non-empty Java package name.
    Fixes jextract accepts an empty javaPackage and emits invalid Java source in JNI and FFM modes #919

Test plan

  • swift test --filter JavaPackageValidationTests (nil, empty, whitespace, empty segments, valid package unchanged; SwiftToJava.run() for nil and "")
  • swift test --filter InputSwiftTests (valid javaPackage still generates)
  • CLI: --java-package '', omitted --java-package, and --mode ffm all fail with the missing-package error and write no output
  • CLI: --java-package com.example.myswiftlibrary still succeeds and emits package com.example.myswiftlibrary;

@bhanage-viraj

Copy link
Copy Markdown
Author

@ktoso This pull request is ready for review

@ktoso

ktoso commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks, some national holidays over here the next days, will review as soon as I can

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.

jextract accepts an empty javaPackage and emits invalid Java source in JNI and FFM modes

2 participants