Skip to content

Java logic natively on Swift supported OS? #786

@bastie

Description

@bastie

This project is under active development. We welcome feedback about any issues you encounter.

Hey everyone,

Anyone who has ever faced the task of porting complex, battle-tested business logic from a Java (or COBOL) monolith over to Swift knows the pain: a complete rewrite is a budget black hole, and bridges are often clunky.
I wanted to kick off a discussion on another way to port the (https://github.com/bastie/JavApi4Swift) — especially when paired with modern AI—is a perhaps this can be game-changer for legacy migrations.

The Core Concept: Native Java API, Zero JVM Overhead

Unlike traditional bridging, JavApi4Swift re-implements the Java standard library natively in pure Swift. This allows you to map Java code almost 1:1 onto Swift structures without needing a Java Virtual Machine (JVM) at runtime.
This creates a massive advantage over Apple's official solutions, such as the swift-java interop bridge:

The Showstopper in Closed Apple Ecosystems
Apple’s own swift-java bridge is amazing if you are building server-side applications (on Linux or macOS) where you control the environment. But here is the catch: it requires a live JVM running under the hood. * If you are deploying to iOS, iPadOS, watchOS, or tvOS, you immediately hit a brick wall.
Apple’s strict sandboxing and App Store review guidelines inherently block running or dynamic-loading a traditional JVM on consumer devices.
The JavApi4Swift Advantage: Because the compiled result is 100% native Swift code, your ported logic runs flawlessly across the entire closed Apple ecosystem—with full App Store compliance and zero performance or binary size penalty.

Perfect Complements, Not Competitors!

We shouldn't look at these two technologies as rivals. In a modern enterprise architecture, they actually complement each other perfectly:
On the Server: You use Apple’s swift-java bridge to communicate directly with your existing, massive Java backend infrastructure.
On the Client (iOS/Mac App): You use the code ported via JavApi4Swift to run the exact same validation or calculation logic offline and natively on the user's device.

The AI Leverage: Automating the Grunt Work
Here is where it gets really interesting for us: Because the project's documentation lays down incredibly strict, predictable rules on how to map Java constructs, it is the perfect food for LLMs.
If you feed a modern AI the Java source code alongside the JavApi style guide, it can convert complex Java libraries with about 80–90% accuracy right out of the box. The rest is just iterative compiler-error fixing.
What are your thoughts on Java-to-Swift migrations? Have any of you experimented with this repo for modular ports, or do you see the same potential in client-side AI porting?

Let's discuss!

(text KI generated)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions