Swift/Java Interop Community Call #3: December 16th

Hi everyone,
Given December being a bit chaotic I had to change the day of the week of the sync... I hope most folks would be able to participate, if not, there's always next time in January. Thank you for participating in the Java interop community!

The primary purpose of these calls is to coordinate work and collaborate on developing Java interoperability (swift-java), including any support tools like gradle or swiftpm plugins etc. If you'd like to contribute in any capacity, please don't hesitate to join.

Previous meeting

Meeting notes and follow ups are in the previous call thread:

Event Details

When: 2025-12-16T14:00:00Z (click to see the time in your timezone)

We found the time to work relatively well and span 4 very different timezones, please cooperate with us as we continue with this timeslot. We may choose different times in the future.

Where: The meeting will hosted on Webex, make sure to install the app before joining.

Agenda

While this isn't an official workgroup meeting per se, we'd like to keep it focused on development tasks: how to improve, coordinate, or plan the future development of swift java interoperability. If you have experience, or are interested in gaining experience, developing language interop, this is the place to be!

See you all soon, Konrad

4 Likes

Hi folks. On the last call, I promised to create issues in SwiftPM regarding integrating SwiftPM dependencies with another build system. Here they are:

I hope these make sense. Perhaps the issue about Objective-C compilations is not as relevant for Swift Java work, but I have a general question: what is the reason Swift Java uses Swift Syntax instead of using the internal Swift compiler APIs directly? From my understanding, Swift Java currently doesn't have a typed understanding of its Swift dependencies. Is there a possibility that in the future it will need to understand the ".swiftmodule" and ".swiftinterface" files similarly to how the Swift compiler understands them?

I believe the linkage issues have more parallels, especially if we consider trying to consume arbitrary SwiftPM dependencies in Gradle JVM compilations and executions.

1 Like

It was a goal to not “put more other language support stuff” into the Swift compiler. Swift’s C++ interop is deeply embedded in the Swift compiler but that is primarily because of Clang. It was a goal to see if we can pull it off without having to tie the language interop with the specific compiler. If necessary, we can do changes in the compiler to support the interop, but it would be better of those are generally useful features for all kinds of languages, rather than every language hacking in their ad-hoc interop pieces.

In other words: we’re trying to decouple the evolution and features offered by swift-java from being specifically tied to a specific compiler in order to evolve it more quickly and independently. If there are things we’d need the compiler’s help for it is possible to make changes, but if we do, hopefully we’d manifest them as “generally useful” features that many languages could benefit from.

1 Like

Thank you! We can talk about them a bit in the call as well. @dschaefer2 FYI

The meeting link is live!

During today's call, I mentioned that SwiftPM can promote transitive products to dynamic libraries. I was only half-correct: xcodebuild does it, and I assumed swift build does it as well, but it instead duplicates machine code. I extracted a reproduction to a sample with some mutable state to illustrate a difference in behavior that produces:

I am wondering whether what swift build does is desirable and expected; the xcodebuild behavior is something I would expect, and I see if you explicitly mark the shared producer’s product as type: .static, xcodebuild complains about:

error: Swift package product 'producer' is linked as a static library by 'executable' and 2 other targets. This will result in duplication of library code.

cc: @dschaefer2

1 Like

I assumed swift build does it as well, but it instead duplicates machine code

This has been irksome to us as well (I touch upon it in swift-java/issues/419), which results in Skip having to raise a build warning for Android builds when it detects that multiple dependency paths lead to a product that is not explicitly marked as .dynamic, and causing us to have to make all our libraries dynamic.

I think xcodebuild does the right thing here, and swift build should replicate its behavior.

1 Like

We’ll have to check.

Just a reminder that we generally don’t talk about the details behind xcodebuild on open source channels. I’ll just say that it is does not necessarily build the exact same way as SwiftPM.

1 Like

Swift Java Community Call Notes: 3

Action follow-ups from last time

New folks joining?

  • Mads
  • Bartek
  • Konrad
  • Doug
  • Thomas K
  • Sam K – first time, works with Doug on SwiftPM
  • Timofey
  • Gregorio
  • Joannis

Agenda

Gradle plugin discussions

  • Timofey did a great PoC for the Gradle plugin driving the jextract calls
  • Q: might we use something more than sourcekit? understand types etc.
    • Konrad: we can modify Swift if we really needed to, but goal is to have more "libs" for lookups etc
      • In general we’re able to do qualified type lookups etc just within swift-java and using
  • context for question is: rely on compiler to dump compiler arguments
  • SWIFT_EXEC is likely to stay
    • is the workaround KN is doing to capture the invocation arguments
  • E.g. Allowing to override LD in swift-build isn't a thing we think
    • pif configuration, more freely allowing to set those?
  • :a: ACTION: @Timofey_Solonin to followow up on @dschaefer2‘s request: let's document what you want and we can discuss it.
    • Maybe SwiftPM could expose what it will produce, and then pass it to gradle to pass to jextract

Doug quick update on prebuilts

  • Working on it
  • will allow using prebuilts from build plugin tools
  • likely in upcoming release

Sandbox and swiftpm restructions vs advanced swift-java trickery

  • Mads, SwiftPM plugin drives whole thing
    • Disables sandbox

What the SwiftPM plugin does:

  • generates: swift
  • generates: java
  • <<<< javac + this has dependencies
  • Feed this java INTO plugin again
  • invoke swift-java again with new sources

Limitations:

  • executables: we call an executable: javac, gradle
  • network: gradle may fetch dependencies (or even just the wrapper)

Konrad: We may need a capabilities model for these plugins, like command plugins do.

Timofey: Similar needs:

  • would also want to invoke gradle sometimes

  • more ability to "call other tool" would be welcome

  • :a: ACTION: Konrad,Mads: how precise can network sandbox be?

    • Document the requirements to invoke the swift-java tool and Gradle etc.
    • We may need swift build plugins to gain permissions basically; document exactly what we need