Skip to content
CAI
Software that uses CAICheck a score

swiftlang/swift-java

60.5

Adequate · 15 November 2026

42.3k

lines of production code

Swift

with Java

5

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Features

Add Android API level support and Java class file parsing infrastructure

The tool library now includes support for Android API versioning and deeper Java class introspection. It introduces an \AndroidAPILevel\ enum mirroring Android SDK version codes and an \AndroidAPIVersions\ parser that reads \api-versions.xml\ to track when classes, methods, and fields were introduced, removed, or deprecated. Additionally, a new \JavaClassFileReader\ parses JVM \.class\ files to extract RuntimeInvisibleAnnotations (such as \@RequiresApi\), enabling the tool to respect class-retained annotations that are not visible via standard reflection.

Sources/SwiftJavaToolLib · high confidence

Add CI validation script and Gradle wrappers to Java dependency sample app

The JavaDependencySampleApp now includes a ci-validate.sh script that automates the build and dependency resolution process, specifically handling the disabling of experimental prebuilts on non-Darwin platforms to work around known issues. Additionally, symbolic links for the Gradle wrapper (gradlew, gradlew.bat, and the gradle directory) have been added to ensure the sample app can correctly invoke the shared Gradle tooling for dependency management.

Samples/JavaDependencySampleApp · high confidence

Add ExampleSwiftLibrary sample for jextract-swift interoperability

Introduces the ExampleSwiftLibrary source file, providing a plain Swift implementation of various global functions and a class (MySwiftClass) designed to be exported to Java via the jextract-swift tool. The library demonstrates support for exporting Swift functions that accept and return primitive types (Int, Long, Double), functional interfaces (Runnable, Suppliers, Consumers, Predicates, Unary/Binary Operators), and raw buffer pointers, along with a Swift class featuring properties, initializers, and methods to validate cross-language binding.

Sources/ExampleSwiftLibrary · high confidence

Add Java ClassLoader binding

The tool now includes a binding for the Java \java.lang.ClassLoader\ class, exposing the \loadClass\ instance method and the \getSystemClassLoader\ static method to Swift code, enabling direct interaction with Java's class loading mechanisms.

Sources/SwiftJavaTool/Java · high confidence

Add Java Commons CSV sample with dependency configuration

The JavaDependencySampleApp now includes a sample demonstrating the use of the Apache Commons CSV library. This addition introduces a configuration file that declares the \org.apache.commons:commons-csv:1.12.0\ dependency and specifies the Java classes to be wrapped (such as \CSVFormat\, \CSVParser\, and \CSVRecord\), along with a dummy source file to satisfy build requirements.

Samples/JavaDependencySampleApp/Sources/JavaCommonsCSV · high confidence

Add Java sample demonstrating Swift interop via FFM and JNI

The sample application now includes a new Java entry point, HelloJava2Swift.java, which demonstrates calling Swift code from Java using both Foreign Function & Memory (FFM) and JNI. The example showcases key interoperability features such as passing strings, integers, and data objects, managing Swift object lifecycles with arenas, handling callbacks, and resolving overloaded function signatures.

Samples/SwiftJavaExtractFFMSampleApp/src/main · high confidence

Add Java type definitions for SwiftKit collections, JDK functions, and tuples

The JExtract tool now includes built-in support for mapping Swift types to specific Java counterparts. This change adds definitions for native-backed Swift collections (SwiftDictionaryMap, SwiftSet), standard JDK functional interfaces (such as IntSupplier, LongConsumer, and various Unary/Binary operators), and Swift tuple types (including labeled tuples with arity up to 24). It also introduces handling for Swift errors via SwiftJavaErrorException and integer overflow checks via SwiftIntegerOverflowException, enabling more accurate and idiatic Java bindings for these Swift constructs.

Sources/JExtractSwiftLib/JavaTypes · high confidence

Add JavaIO and CSV example to SwiftJava sample app

The JavaDependencySample app now includes a demonstration of integrating Java libraries, specifically Apache Commons IO and Commons CSV. The sample code initializes a JVM, retrieves the file extension for a path using FilenameUtils, and parses a CSV string using CSVFormat, illustrating how Swift code can interact with these Java dependencies.

Samples/JavaDependencySampleApp/Sources/JavaDependencySample · high confidence

Add JavaProbablyPrime sample app

A new sample application, JavaProbablyPrime, has been added to demonstrate using SwiftJava to call Java APIs from a Swift command-line tool. The sample includes a Swift source file that uses ArgumentParser to accept a number and a certainty level, then utilizes the java.math.BigInteger class (mapped via swift-java.config) to check if the input number is probably prime.

Samples/JavaProbablyPrime/Sources · high confidence

Add JavaProbablyPrime sample demonstrating Java API usage from Swift

A new sample project, JavaProbablyPrime, has been added to demonstrate how to use Java APIs from Swift. It shows how to wrap the java.math.BigInteger type using the SwiftJavaPlugin build tool plugin and call its isProbablePrime method. The sample includes a README explaining the usage and a CI validation script to verify the functionality.

Samples/JavaProbablyPrime · high confidence

Add JavaSieve sample demonstrating Java library integration from Swift

A new sample project, JavaSieve, has been added to demonstrate how to import and use a Java library distributed as a JAR file within Swift. The sample includes configuration files (swift-java.config) to map Java classes like SieveOfEratosthenes to Swift types, and source code showing how to initialize the JVM and call Java methods, such as finding prime numbers, directly from Swift.

Samples/JavaSieve · high confidence

Add Swift error integration for Java exceptions and throwables

The SwiftJava Exceptions module now provides seamless interoperability between Java exceptions and Swift's error handling. Users can now check if a Java exception is checked or unchecked via the new \isCheckedException\ property on \Exception\ and \Throwable\ classes. Additionally, \Throwable\ instances automatically conform to Swift's \Error\ protocol, allowing them to be thrown and caught using standard Swift \do-catch\ blocks. The \JNIEnvironment\ extension adds helper methods to translate JNI exceptions into Swift errors (\translatingJNIExceptions\), throw Swift errors as Java exceptions (\throwAsException\), and throw specific Java exceptions (\throwJavaException\), simplifying error propagation across the Swift-Java boundary.

Sources/SwiftJava/Exceptions · high confidence

Add Swift sample type in library subdirectory

A new Swift source file, SwiftTypeInSubDirectory.swift, has been added to the LibrarySubDirectory of the MySwiftLibrary sample. This file defines a public final class containing a hello method that returns an integer, serving as a sample implementation for the SwiftJavaExtractFFMSampleApp.

Samples/SwiftJavaExtractFFMSampleApp/Sources/MySwiftLibrary/LibrarySubDirectory · high confidence

Add Swift-Java JNI implementation for HelloJava2Swift

The sample application now includes a new JNI implementation file that exposes the \com.example.swift.HelloJava2Swift\ Java class to Swift. This file defines the \HelloJava2SwiftNativeMethods\ protocol and implements two native methods: \jniWriteString\, which returns the character count of a provided message, and \jniGetInt\, which returns a fixed integer value of 12.

Samples/SwiftJavaExtractFFMSampleApp/Sources/MySwiftLibrary/jni · high confidence

Add Swift-Java JNI sample application

A new sample application (HelloJava2SwiftJNI.java) has been added to demonstrate interoperability between Java and Swift via JNI. The sample illustrates how to use the SwiftKit library to call Swift functions from Java, manage memory using SwiftArena, and interact with Swift classes and structs.

Samples/SwiftJavaExtractJNISampleApp/src/main · high confidence

Add SwiftJavaError wrapper and FFI runtime functions for error handling

Introduces the SwiftJavaError class to wrap Swift errors for safe passage across the FFI boundary, along with generated thunks that expose error descriptions and type information to Java. This change is accompanied by the addition of core runtime helper functions in SwiftRuntimeFunctions.swift, including memory management wrappers (retain, release, retainCount, isUniquelyReferenced), type lookup by string, and string-to-C-string conversion, enabling robust error propagation and object lifecycle management in FFM/JNI modes.

Sources/SwiftRuntimeFunctions · high confidence

Add reflection utility extensions and configuration for Java standard library

This change introduces a new \JavaLangReflect\ module that provides convenience extensions for Java reflection types. It adds modifier-checking properties (such as \isPublic\, \isStatic\, \isNative\, and \isFinal\) to \Constructor\, \Method\, and \Field\ via a shared \HasJavaModifiers\ protocol, and adds \throwsCheckedException\ to \Executable\. It also includes \CustomStringConvertible\ implementations for \Type\, \ParameterizedType\, and \TypeVariable\, along with a configuration file mapping Java reflection classes to their Swift counterparts.

Sources/JavaStdlib/JavaLangReflect · high confidence

Added CI validation script for JavaKitSampleApp

A new shell script (ci-validate.sh) has been added to the JavaKitSampleApp sample to automate validation of the Java integration. The script builds the project with tests, runs the generated Java application entry points (including one with Swift-based argument parsing), and executes the Swift test suite, while applying a workaround to disable experimental prebuilts on non-Darwin platforms.

Samples/JavaKitSampleApp · high confidence

Added Java API call benchmark

A new benchmark file has been added to the Benchmarks module to measure the performance of simple calls to the Java library, specifically testing the retrieval of default user interaction settings from the URLConnection class via the SwiftJava bridge.

Benchmarks · high confidence

Added Java IO configuration for standard library classes

A new configuration file (swift-java.config) has been added to the JavaIO module, defining mappings for key Java IO classes including BufferedInputStream, InputStreamReader, Reader, FileReader, StringReader, FileDescriptor, and WatchService. This establishes the binding configuration required for these specific standard library components within the SwiftJava framework.

Sources/JavaStdlib/JavaIO · high confidence

Added Java URL/URI conversion helpers and updated JavaNet configuration

Users can now easily convert between Swift's Foundation URL and Java's java.net.URL via new extension methods (fromJava/fromSwift) in JavaURL+URIConversions.swift. The JavaNet module configuration has been updated to explicitly extend java.net.URL, java.io.File, and java.nio.file.Path, and to map java.net.URI, URLClassLoader, URLConnection, and HttpURLConnection to their Swift counterparts.

Sources/JavaStdlib/JavaNet · high confidence

Expanded Swift-to-Java JNI sample library with new type and behavior coverage

The \MySwiftLibrary\ sample source has been significantly expanded to demonstrate a broader range of \jextract\ JNI capabilities. The library now includes dedicated modules for testing asynchronous methods (\Async.swift\), Swift actors and isolated parameters (\Isolated.swift\), and distributed actors (\Distributed.swift\). Support for complex data structures is demonstrated through new files handling arrays (\Arrays.swift\), dictionaries (\Dictionary.swift\), sets (\CollectionBoxable.swift\), and Foundation types like \Data\, \Date\, \UUID\, and \URL\. The sample also exercises advanced Swift features such as generic types (\GenericType.swift\), protocol inheritance and existential boxes (\ProtocolA\, \ProtocolB\, \ProtocolC\, \ConcreteProtocolAB.swift\), escaping closures (\Closures.swift\, \EscapingClosures.swift\), and custom operators (\Operators.swift\). Additionally, a new \MySwiftDependencyLibrary\ module with a \swift-java.config\ file illustrates cross-module type resolution.

Samples/SwiftJavaExtractJNISampleApp/Sources · high confidence

Generated Swift wrappers for java.lang.reflect classes

The \Sources/JavaStdlib/JavaLangReflect/generated\ directory now contains auto-generated Swift wrappers for the \java.lang.reflect\ package, including \AccessibleObject\, \AnnotatedType\, \Annotation\, \Array\, \Constructor\, \Executable\, \Field\, \GenericArrayType\, \GenericDeclaration\, \JavaClass\ extensions, \Method\, \Parameter\, and \ParameterizedType\. These files expose Java reflection capabilities—such as accessing fields, invoking methods, inspecting annotations, and handling generic types—directly in Swift via the \SwiftJava\ and \SwiftJavaJNICore\ modules.

Sources/JavaStdlib/JavaLangReflect/generated · high confidence

Generated Swift wrappers for java.net classes

The \Sources/JavaStdlib/JavaNet/generated\ directory now contains auto-generated Swift wrappers for core Java networking classes, including \URI\, \URL\, \File\, \Path\, \URLConnection\, \HttpURLConnection\, and \URLClassLoader\. These files expose Java constructors, static fields (such as HTTP status codes in \HttpURLConnection\), and instance methods (like \connect\, \getContentType\, and \toURI\) to Swift, enabling direct interaction with the Java standard library's networking and file-path APIs from Swift code.

Sources/JavaStdlib/JavaNet/generated · high confidence

Generated Swift wrappers for java.util.function interfaces and collection extensions

This update adds auto-generated Swift bindings for the Java \java.util.function\ package, including functional interfaces like \Consumer\, \Function\, \Predicate\, \Supplier\, and their primitive specializations (e.g., \IntConsumer\, \DoubleFunction\). It also introduces extension methods on Swift wrappers for Java collections (\ArrayList\, \HashMap\, \Collection\, \Map\, \Set\, \Optional\, etc.) to expose Java 8+ functional methods such as \forEach\, \removeIf\, \compute\, \map\, and \filter\, enabling idiomatic functional programming patterns when interacting with Java libraries from Swift.

Sources/JavaStdlib/JavaUtilFunction/generated · high confidence

Initial documentation for Swift-Java interoperability

The Swift-Java documentation site is now available, providing comprehensive guides for both directions of interoperability. It covers the \jextract\ tool for exposing Swift code to Java (including JNI and FFM modes, feature support, and binary size optimization) and the \wrap-java\ tool plus JavaKit macros for calling Java from Swift. The documentation also includes specific guides for Android integration (R8/ProGuard rules, Core Library Desugaring, and API availability), the \swift-java\ command-line interface, the SwiftPM build plugins, and the \swift-java.config\ file schema.

Sources/SwiftJavaDocumentation · high confidence

Initial project scaffolding and documentation

The repository has been initialized with the core project structure, including the Apache 2.0 license, a comprehensive README detailing Swift and Java interoperability tools, and a CONTRIBUTING guide for local CI execution. Build infrastructure is established via Gradle wrapper scripts and configuration, while developer tooling is standardized through \.editorconfig\, \.swift-format\, and \.gitignore\ files to enforce consistent code style and ignore build artifacts.

(repo-wide) · high confidence

Introduce CDeclLowering to bridge Swift types to C-compatible representations

The JExtract tool now includes a new CDeclLowering module that translates Swift function signatures into C-compatible \@\_cdecl\ representations. This enables the extraction of Swift APIs by lowering complex types—such as pointers, optionals, and functions—into standard C types, while explicitly rejecting unsupported features like async, isolated, or throwing functions in this specific lowering path. This change provides the foundational type mapping logic required for generating C entrypoints for Swift code.

Sources/JExtractSwiftLib/FFM/CDeclLowering · high confidence

Introduce Docker-based development and CI environment

Adds a new Docker setup including a Dockerfile, docker-compose configurations, and a JDK installation script to standardize the build environment. The environment is configured to use Swift nightly builds on Ubuntu Jammy and installs JDK 25 (Amazon Corretto) to support the latest Foreign Function Interface (FFI) while remaining compatible with Gradle, ensuring consistent local and CI execution for Swift and Java tests.

docker · high confidence

Introduce FFM-based Swift-to-Java code generation

The \JExtractSwiftLib/FFM\ module now provides a new code generation path using Java's Foreign Function & Memory API (FFM) alongside the existing JNI approach. This adds support for generating Java bindings for Swift APIs, including specific handling for \Foundation.Data\ (with helpers like \fromByteArray\, \toMemorySegment\, and \toByteBuffer\), Swift tuples, closures, and variadic functions. It also introduces 32-bit integer overflow checking for FFM downcalls and allows configuring the native library name via \swift-java.config\.

Sources/JExtractSwiftLib/FFM · high confidence

Introduce FFM-based memory arenas and instance lifecycle management

SwiftKitFFM now provides two memory arena strategies for managing native Swift resources from Java: a confined arena via \AllocatingSwiftArena.ofConfined()\ for explicit, deterministic cleanup, and an auto arena via \AllocatingSwiftArena.ofAuto()\ that relies on the Java Garbage Collector to trigger native cleanup. This change introduces the \FFMSwiftInstance\ and \FFMSwiftErrorInstance\ base classes to handle memory segments and type metadata, along with \FFMSwiftInstanceCleanup\ to safely destroy native values and detect double-destruction. It also adds runtime utilities for loading Swift libraries, handling C strings, and accessing Swift value witness tables for type layout and destruction.

SwiftKitFFM · high confidence

Introduce JNI code generation infrastructure for Swift-to-Java bridging

The \Sources/JExtractSwiftLib/JNI\ location now contains the core implementation for the \jextract\ tool's JNI mode, enabling the automatic generation of Java bindings for Swift code. This change adds the \JNISwift2JavaGenerator\ and its supporting modules to translate Swift types, functions, and protocols into Java classes and JNI thunks. Key capabilities include mapping Swift primitive and standard library types (such as \String\, \Data\, \Date\, and \UUID\) to their Java equivalents, handling complex types like tuples, optionals, and arrays, and supporting escaping closures via \@JavaInterface\ wrappers. The generator also produces the necessary Swift-side thunk code and linker export lists to facilitate efficient interop between Swift and Java applications.

Sources/JExtractSwiftLib/JNI · high confidence

Introduce Swift Java Build Tool Plugin for generating Java wrappers

Adds the \JExtractSwiftPlugin\, a Swift Package Manager build tool plugin that integrates with the \swift-java\ CLI to automatically generate Java wrappers and Swift bindings for Swift types. The plugin scans for a \swift-java.config\ file in the target directory, processes Swift source files, and outputs generated Java code and Swift thunk files (e.g., \+SwiftJava.swift\) to the standard SPM output directories. It supports cross-module dependency resolution via \--depends-on\, handles JNI-specific requirements like linker export lists for dead code elimination, and optionally generates Java callback wrappers if enabled in the configuration.

Plugins/JExtractSwiftPlugin · high confidence

Introduce SwiftJavaMacros for bridging Swift and Java

The new SwiftJavaMacros module provides the macro infrastructure for interoperating between Swift and Java. It introduces several macros: @JavaClass, @JavaInterface, and @JavaRecord to import Java types into Swift; @ExportToJavaClass to expose Swift types to Java; @JavaImplementation to define Swift extensions that implement native Java methods (including JNI escaping and environment handling); @JavaMethod and @JavaStaticMethod to mark imported Java methods; @JavaField and @JavaStaticField for property access; and @JavaExport as a marker for jextract. The module also includes a GenerationMode enum to distinguish between import, export, and implementation contexts, and a compiler plugin (SwiftJavaMacrosPlugin) that registers these macros.

Sources/SwiftJavaMacros · high confidence

Introduce SwiftJavaPlugin for wrapping Java classes in Swift

A new Swift Package Plugin named SwiftJavaPlugin has been added to the repository. This plugin enables Swift targets to wrap Java classes by reading a \swift-java.config\ file, resolving Java dependencies, and invoking the \swift-java\ tool to generate Swift wrappers. It supports cross-module type resolution via \--depends-on\ for dependent targets and allows Java classes to be implemented natively in Swift.

Plugins/SwiftJavaPlugin · high confidence

Introduce SwiftJavaRuntimeSupport for JNI bridging and type conversions

The new SwiftJavaRuntimeSupport module provides the runtime infrastructure for bridging Swift and Java types via JNI. It includes CollectionBridge for converting Swift collections (Dictionary, Set, Optional, Array) to and from Java objects, JextractedTypeBridge to reduce boilerplate for jextract-generated wrappers, and \_JNIBoxedConversions for handling primitive boxing. The module also introduces \_JNIMethodIDCache for efficient JNI method/field lookups with Android core library desugaring support, and defines configuration mappings for core SwiftKit classes like SwiftInstance and SwiftArena.

Sources/SwiftJavaRuntimeSupport · high confidence

Introduce SwiftKitCore with explicit and automatic memory management arenas

The SwiftKitCore module now provides a new memory management model for bridged Swift objects, offering two distinct lifecycle strategies: confined arenas that require explicit closing to release native resources immediately, and auto arenas that rely on the Java garbage collector for eventual cleanup. This change introduces the \SwiftArena\ interface along with \ConfinedSwiftMemorySession\ and \AutoSwiftMemorySession\ implementations, alongside core infrastructure such as \JNISwiftInstance\ for native instance handling, \SwiftInstanceCleanup\ for safe destruction tracking, and \SwiftLibraries\ for automatic dynamic library loading. Users must now manage the lifetime of Swift objects through these arenas to prevent memory leaks or premature deallocation.

SwiftKitCore · high confidence

Introduce SwiftPM plugin to compile Java sources

A new Swift Package Manager build tool plugin has been added to the JavaCompilerPlugin location, enabling the compilation of Java source files (.java) within a target into class files. The plugin scans the target's sources for Java files, reads configuration from a \swift-java.config\ file (supporting JSON5 format), and invokes the \javac\ compiler. It passes the \-parameters\ flag to preserve parameter names for subsequent Swift wrapper generation and respects any compiler version arguments defined in the configuration. The compiled class files are output to the plugin's work directory.

Plugins/JavaCompilerPlugin · high confidence

Introduce generic, language-specific CodePrinter with Java 23 Javadoc support

The code generation system now uses a generic CodePrinter typed by language (Swift or Java) to provide language-appropriate syntax helpers. For Java output, the printer now supports Java 23+ Javadoc comments using Markdown-style line comments (///) with automatic conversion of inline code tags, falling back to traditional block comments for earlier versions. For Swift output, it adds a guard block helper. The printer also includes configurable inline comment styles and an option to disable source-location debug trailers in generated code.

Sources/CodePrinting · high confidence

Java collections and iterators now conform to Swift Sequence

Java collection types (List, Set, JavaCollection) and iterator types (Enumeration, JavaIterator, ListIterator) in the JavaExtensions module now conform to Swift's Sequence and IteratorProtocol protocols. This allows these Java types to be used directly in Swift idioms such as for-in loops, map, filter, and reduce without requiring manual iteration logic.

Sources/SwiftJava/JavaExtensions · high confidence

Native Swift Set and Dictionary support for JNI bridging

The \Sources/SwiftJava/BridgedValues\ module now supports passing native Swift \Set\ and \Dictionary\ types across the JNI boundary. This is achieved by introducing the \JobjectBridge\ protocol and \JavaBoxable\ conformance for standard types (String, Int64, Int32, Double, Float, Bool, Int8, UInt8), allowing them to be boxed into Java objects. New extensions on \Dictionary\ and \Set\ provide \dictionaryGetJNIValue\ and \setGetJNIValue\ methods to box these collections into retained pointers, while corresponding \init(fromJNI:)\ initializers reconstruct them on the Swift side. Additionally, \SwiftDictionaryMap\ and \SwiftSet\ Java classes are implemented to expose collection operations (size, get/contains, keys/values, toArray) to Java code via JNI method implementations.

Sources/SwiftJava/BridgedValues · high confidence

New Swift and Java FFM sample library with functional interface support

This change introduces a new sample project, Samples/SwiftAndJavaJarFFMSampleLib, that demonstrates exporting plain Swift code to Java using the jextract-swift tool and the Foreign Function & Memory (FFM) API. The sample includes Swift sources (MySwiftClass, MySwiftLibrary) exposing methods and global functions, including support for Java functional interfaces such as Supplier, Consumer, Predicate, and various Unary/Binary Operators. It provides a Java entry point (HelloJava2Swift) and an example usage (Example.java) to call the generated bindings, along with a CI validation script, Gradle build files, JMH benchmarks, and comprehensive JUnit tests verifying the interoperability of these Swift-to-Java calls.

Samples/SwiftAndJavaJarFFMSampleLib · high confidence

New automation scripts for documentation, release, and code generation

The repository now includes a set of shell scripts to streamline development and release workflows. \generate-docs.sh\ and \generate-cli-help-snippets.sh\ automate the creation of static DocC HTML documentation and CLI help snippets, ensuring docs stay in sync with the tool. \release.sh\ automates the release process, including pinning dependencies, verifying builds, and creating release branches. \wrap-java-generate.sh\ and \swiftkit-ffm-generate-bindings.sh\ regenerate Swift and Java bindings from configuration files. Additionally, \run-linkage-test.sh\ verifies that the linkage test suite covers all runtime library products and does not accidentally link against Foundation.

scripts · high confidence

New configuration and dependency parsing infrastructure for SwiftJava

This change introduces the \SwiftJavaConfigurationShared\ module, providing the foundational configuration structures and utilities for the SwiftJava tooling. It adds a comprehensive \Configuration\ struct that allows users to define generation parameters such as Java package names, native library loading behavior, variadic overload limits, access levels, and support for specific Java features like async functions and protocol implementation. Additionally, it includes \GradleDependencyParsing.swift\ to handle the parsing of Gradle-style dependency descriptors, enabling the configuration of Java dependencies within the Swift build system.

Sources/SwiftJavaConfigurationShared · high confidence

New dependency resolution capability and terminal color utilities

This change introduces a new \DependencyResolver\ component that allows users to resolve project dependencies to a classpath and check if dependencies are loaded, with configuration managed via \swift-java.config\. Additionally, it adds \TerminalColors\ support, enabling colored output in terminal tools while respecting the \NO\_COLOR\ environment variable and terminal capabilities.

Sources/JavaKitDependencyResolver · high confidence

Shared plugin utilities and configuration infrastructure

The Plugins/PluginsShared directory now provides a centralized set of utilities and protocols for Swift Java plugins, accessible via symlinks to avoid code duplication. This includes robust JAVA\_HOME detection that falls back to SDKMAN and the system PATH, helper functions for locating swift-java.config files, and standardized output directory paths for generated Java and Swift code. It also introduces a common plugin protocol for logging and a dedicated error type for missing configuration, streamlining how individual plugins handle environment setup and shared logic.

Plugins/PluginsShared · high confidence

jextract: resolve cross-module types via --depends-on

The Swift-to-Java extraction tool now supports resolving types that live in external Swift modules. By using the new \--depends-on\ flag (or configuring \inputSwiftDirectory\ and \swiftModuleName\ in \swift-java.config\), jextract can load source files from dependent modules and inject synthetic stubs for Java wrapper types, ensuring that cross-module references are correctly resolved during analysis and code generation.

Sources/JExtractSwiftLib · high confidence

Behavioural changes

1 commit (0 fixes) modifying (repo-wide)

A change to existing behaviour in (repo-wide) — 1 commit, 47 files: “Split out \SwiftExtract\ into swift-binding-generator-core (\#957)” (refs \#957). Also in this area: Automated documentation generation for swift-java configuration.

Plugins/PluginsShared/SwiftExtractConfigurationShared, Sources/GenerateConfigDocs · medium confidence · unverified

Android Core Library Desugaring support and dynamic class loading fallbacks

SwiftJava now supports Android Core Library Desugaring, automatically mapping desugared classes (such as \java.util.Optional\ variants) to their \j$.\*\ locations on older Android SDKs. Additionally, class lookups now include a fallback to the application class loader when using SwiftJava as a dynamic library, improving reliability in environments where the default loader cannot find wrapped classes.

Sources/SwiftJava · high confidence

Automated documentation generation for swift-java configuration

The \Snippets\ directory has been restructured to use symlinks pointing to actual sample and test files (e.g., from \SwiftJavaExtractJNISampleApp\ and \JavaKitSampleApp\), ensuring that code snippets in documentation are always compiled and validated. Additionally, a new \Sources/GenerateConfigDocs\ tool has been introduced to automatically regenerate the \SwiftJavaConfigFile.md\ documentation from the \Configuration.swift\ source, keeping the supported configuration options in sync with the code.

Snippets · high confidence

Build logic migrated to Kotlin DSL with improved native library path resolution

The BuildLogic module has been rewritten in Kotlin DSL, introducing new convention plugins (java-common, java-application, java-library) and utility functions to streamline the build configuration. A key behavioral change is the more reliable detection of Swift runtime library paths using \swiftc -print-target-info\, which ensures that tests and applications can correctly locate native dependencies on both Linux and macOS. Additionally, the build now automatically registers the directories containing generated Java sources from the JExtractSwiftPlugin, allowing IDEs to index these files without requiring a prior build execution.

BuildLogic · high confidence

CI validation scripts for Swift-JNI sample app

The SwiftJavaExtractJNISampleApp now includes a ci-validate.sh script and Gradle wrapper symlinks to standardize its build and test execution. The script implements platform-specific workarounds for Swift 6.2.1, disabling experimental prebuilts on non-macOS systems and handling Gradle wrapper download timeouts on GitHub Actions macOS runners by pre-loading the wrapper distribution.

Samples/SwiftJavaExtractJNISampleApp · high confidence

Configurable Java Util class mappings via swift-java.config

The JavaUtil module now uses a new \swift-java.config\ file to explicitly map Java standard library classes (such as \java.util.ArrayList\, \java.util.HashMap\, and \java.util.Queue\) to their corresponding Swift implementations. This change centralizes the configuration for how these common utility classes are bridged, replacing previous manual or implicit wiring mechanisms with a declarative mapping structure.

Sources/JavaStdlib/JavaUtil · high confidence

Expanded JavaKit sample app with new demonstration classes

The JavaKit sample application has been reorganized into a dedicated sub-package and now includes several new Java source files to demonstrate broader interoperability features. These additions include HelloJavaKitArrays for array handling, HelloSubclass and HelloSwift for class inheritance and native method callbacks, Point to test Java record support, SwiftArgumentParserMain to show Swift-based argument parsing, and ThreadSafe/ThreadSafeHelperClass to demonstrate thread-safety annotations and Java Optional types.

Samples/JavaKitSampleApp/Sources/JavaKitExample/com · high confidence

Expanded sample library for FFM-based Swift-to-Java extraction

The MySwiftLibrary sample source files have been replaced with a comprehensive set of Swift declarations designed to exercise the FFM (Foreign Function Manager) extraction mode. The new library includes functions and types for handling Java functional interfaces (such as IntSupplier, LongConsumer, and DoublePredicate), Swift tuples, optionals, and throwing functions. It also adds support for Foundation.Data, UnsafeRawBufferPointer, and typealiases, providing a broader demonstration of how Swift code is translated to Java under the FFM backend.

Samples/SwiftJavaExtractFFMSampleApp/Sources/MySwiftLibrary · high confidence

Introduce JExtractSwiftLib convenience utilities for Java type mapping and JNI naming

The JExtractSwiftLib module now includes a set of convenience extensions to support Java type mapping and JNI symbol generation. JavaType gains helpers for computing JNI type signatures, determining optional wrapper types (such as OptionalInt), and handling boxing for primitive types. String extensions provide utilities for escaping JNI identifiers, parsing Java class names from SwiftJava lookups, and generating JNI C symbol names and Java binary names for nested synthetic types. Additionally, a new JavaTypeAnnotations helper detects when Swift unsigned integer types require specific Java annotations.

Sources/JExtractSwiftLib/Convenience · high confidence

Introduce dedicated subcommands for swift-java configuration and dependency resolution

The swift-java tool now exposes distinct subcommands to separate concerns: \configure\ generates or amends the \swift-java.config\ file from JARs or classpaths with support for include/exclude filters; \resolve\ fetches Maven-style dependencies and writes the resulting classpath to a module-specific \.swift-java.classpath\ file; \jextract\ handles extracting Java bindings from Swift sources with options for dependency resolution (\--depends-on\), filtering, and single-type generation; \wrap-java\ wraps Java classes into Swift bindings with dependency and filtering support; and \java-callbacks-build\ consolidates the Gradle, javac, configure, and wrap-java steps into a single command to avoid linking Foundation in build plugins. This restructuring disentangles the previous monolithic command flow, giving users explicit control over configuration, dependency resolution, and code generation stages.

Sources/SwiftJavaTool/Commands · high confidence

JNI method ID caching for improved performance

JavaKit now includes an internal cache for JNI method and class references to optimize the performance of JNI lookups in generated wrappers. This change introduces a new helper class that pre-resolves method IDs and maintains global references to Java classes, reducing the overhead of repeated native calls during runtime.

Sources/JavaKit · high confidence

Java collection types now conform to JavaCollectionProtocol

Users can now treat Java standard library collection types (ArrayList, ArrayDeque, HashSet, TreeSet, PriorityQueue, and Queue) as Java collections via the new JavaCollectionProtocol conformance, enabling consistent collection-based operations across these types.

Sources/JavaStdlib/JavaUtil/JavaExtensions · high confidence

Java stdlib function module configuration added

A new configuration file for the \java.util.function\ module has been introduced, defining Swift type mappings for standard Java functional interfaces (such as \Consumer\, \Function\, \Predicate\, and \Supplier\) and specifying classes to extend, including \java.util.Optional\ variants and common collection types.

Sources/JavaStdlib/JavaUtilFunction · high confidence

JavaKit sample app restructured with new optional mapping and ArgumentParser integration

The JavaKitExample sample has been reorganized into its own sub-package and updated to demonstrate new language features. The sample now includes a SwiftArgumentParserMain component that shows how Java native entry points can delegate to Swift ArgumentParser commands. The core JavaKitExample.swift implementation has been expanded to showcase optional mapping support, allowing Swift code to handle nullable Java types, and demonstrates the new @ThreadSafe annotation by exposing Sendable conformance for thread-safe Java classes.

Samples/JavaKitSampleApp/Sources/JavaKitExample · high confidence

New JExtract configuration options for async modes, generation backends, and Java source levels

The JExtract tooling now exposes explicit configuration enums that let users control code generation behavior. Users can choose how Swift \async\ functions are mapped to Java via \JExtractAsyncFuncMode\ (returning \CompletableFuture\ or the legacy \Future\ for older Android platforms). The generation backend is configurable via \JExtractGenerationMode\, allowing a switch between the default Foreign Function and Memory (FFM) API and the Java Native Interface (JNI). Memory management strategies are defined in \JExtractMemoryManagementMode\, offering either explicit \SwiftArena\ usage or an automatic global arena. Additionally, \JavaSourceLevel\ allows targeting specific JDK versions (17–25) to control available language features, such as JDK 18+ JavaDoc snippets, with \JavaSourceFeature\ providing a mechanism to conditionally enable source-level-dependent constructs.

Sources/SwiftJavaConfigurationShared/JExtract · high confidence

Refactor swift-java CLI into a modular subcommand architecture

The swift-java command-line tool has been restructured to replace its previous ad-hoc argument parsing with a formal subcommand model (configure, resolve, wrap-java, jextract, and JavaCallbacksBuild). This change introduces shared CommonOptions for consistent handling of output directories, log levels, and configuration paths across all modes, and adds a CommonJVMOptions extension to unify classpath resolution from environment variables, config files, and command-line flags. Additionally, the tool now prevents crashes when no subcommand is specified by printing usage instructions, and introduces a hardcoded exclusion list for specific JDK types (java.lang.Enum) to prevent import errors.

Sources/SwiftJavaTool · high confidence

Regenerated Java IO wrapper bindings

The generated Swift wrappers for \java.io\ and \java.nio.file\ classes have been regenerated to align with the updated \wrap-java\ tooling. This update refreshes the bindings for \BufferedInputStream\, \FileDescriptor\, \FileReader\, \InputStreamReader\, \Reader\, \StringReader\, and \WatchService\, ensuring that method signatures, inheritance structures, and static fields (such as \FileDescriptor.in\, \out\, and \err\) accurately reflect the current Java standard library definitions.

Sources/JavaStdlib/JavaIO/generated · high confidence

Regenerated Java standard library wrappers

The auto-generated Swift wrappers for \java.util\ classes (including \ArrayDeque\, \ArrayList\, \HashMap\, \HashSet\, \LinkedList\, \PriorityQueue\, \Queue\, \TreeMap\, \TreeSet\, and others) have been regenerated using the \wrap-java\ tool. This update refreshes the generated code to align with the current state of the Java-to-Swift wrapper generator, ensuring the bindings remain consistent with the underlying Java API signatures.

Sources/JavaStdlib/JavaUtil/generated · high confidence

Regenerated Java-to-Swift runtime support wrappers

The generated Swift wrappers for the Java-to-Swift runtime support layer have been regenerated, introducing new bindings for core memory management and instance handling. Specifically, the update adds \JavaJNISwiftInstance\ to expose JNI-specific instance methods like \$memoryAddress\ and \$typeMetadataAddress\, defines \JavaSwiftArena\ with an \ofAuto\ factory method and a \register\ capability, and provides \JavaSwiftMemoryManagement\ which exposes the \DEFAULT\_SWIFT\_JAVA\_AUTO\_ARENA\ static field. These changes ensure the Swift side correctly mirrors the updated Java \SwiftInstance\, \SwiftArena\, and \SwiftMemoryManagement\ interfaces.

Sources/SwiftJavaRuntimeSupport/generated · high confidence

Regenerated Java-to-Swift wrappers for java.util.jar and java.util.zip

The generated Swift bindings in Sources/JavaStdlib/JavaUtilJar have been regenerated using the updated wrap-java tool, introducing stable output ordering. This update refreshes the Swift wrappers for java.util.jar classes (Attributes, JarEntry, JarFile, JarInputStream, JarOutputStream, Manifest) and java.util.zip.ZipEntry, ensuring they align with the current Java signatures and the centralized SwiftJava naming conventions.

Sources/JavaStdlib/JavaUtilJar · high confidence

Regenerated Java-to-Swift wrappers with improved iterator and sequence support

The auto-generated Swift wrappers for Java classes have been regenerated to include new Swift standard library extensions. \Enumeration\ and \JavaIterator\ now conform to \IteratorProtocol\, and \List\ conforms to \Sequence\, allowing these Java collections to be used directly in Swift \for-in\ loops and other sequence-based APIs. The generated code also reflects updates to the underlying \SwiftJavaJNICore\ module and includes fixes for generic parameter handling and method generation.

Sources/SwiftJava/generated · high confidence

Test coverage

Added JMH benchmarks for Swift-JNI interoperability features; Added JMH benchmarks for Swift-Java interop performance; Added Java test coverage for the FFM sample app; Added Java unit tests for the Swift-JNI sample application; Added LinkageTest to verify SwiftJava module dependencies; Added macro expansion tests for SwiftJava; Added runtime tests for JavaKit sample app; Added test assertion helpers for lowering and output verification; Added test configuration for Java dependencies; Added test coverage for JExtractSwift; Added test coverage for SwiftJavaToolLib WrapJava functionality; Added test suite for SwiftJavaToolLib; Added tests for Android desugaring and basic Java runtime interactions; Added tests for FFM code generation capabilities; Added tests for Gradle dependency parsing and JSON configuration with comments; Added tests for JExtract JNI code generation; Added tests for SwiftKit FFM sample app; Added tests for inline comment styles and Java documentation comment formatting.

Dependencies

154 commits updating dependencies (31 manifests)

A dependency / build maintenance change in (dependencies) — 154 commits (10 fixs), 31 files: “Preparing release 0.3.0 (\#745)”; “Remove swift-java executable target from Package.swift (\#771)”; “jextract: resolve cross-module types via --depends-on (\#766)”; and 150 more (refs \#745, \#771, \#766, \#493, \#14, …).

(dependencies) · medium confidence · unverified

Gradle wrapper updated to version 9.4.0

The Gradle wrapper configuration has been updated to use Gradle 9.4.0. This change ensures that the build tool is automatically downloaded and used, standardizing the build environment for all developers and CI systems without requiring manual installation of a specific Gradle version.

gradle · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 60 → 61 (+1.0)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.

Lenses

  • Code Health 60 → 54 (-5.7)
  • Architecture 94 → 93 (-0.8)
  • Maturity 56 → 61 (+4.8)
  • Readiness 54 → 58 (+3.5)
  • Security 78 → 78 (+0.0)
  • Performance 88 → 100 (+12.1)

Resolved (68)

  • AnalysisResult.typesConforming (cognitive 19) (Sources/SwiftExtract/AnalysisResult.swift)
  • Change coupling: SwiftAnalysisVisitor.swift ↔ SwiftSymbolTable.swift (Sources/SwiftExtract/SwiftAnalysisVisitor.swift)
  • ClassTooLong: SwiftAnalysisVisitor (Sources/SwiftExtract/SwiftAnalysisVisitor.swift)
  • Duplicated block (10 lines × 2) (Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaBindingsPrinting.swift)
  • Duplicated block (11–12 lines × 2) (Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaBindingsPrinting.swift)
  • Duplicated block (11–12 lines × 2) (Sources/SwiftExtract/SwiftFileFilter.swift)
  • Duplicated block (12 lines × 2) (Sources/SwiftExtract/SwiftTypes/SwiftFunctionSignature.swift)
  • Duplicated block (13–14 lines × 2) (Sources/SwiftExtract/SwiftTypes/SwiftType.swift)
  • Duplicated block (14 lines × 2) (Sources/SwiftJava/JavaObject+MethodCalls.swift)
  • Duplicated block (18 lines × 2) (Sources/SwiftExtract/SwiftTypes/SwiftFunctionSignature.swift)
  • Duplicated block (4–8 lines × 3) (Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift)
  • Duplicated block (5 lines × 2) (Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaBindingsPrinting.swift)
  • Duplicated block (5 lines × 2) (Sources/SwiftExtract/SwiftTypes/SwiftNominalTypeDeclaration.swift)
  • Duplicated block (5 lines × 3) (Sources/JExtractSwiftLib/FFM/CDeclLowering/FFMSwift2JavaGenerator+FunctionLowering.swift)
  • Duplicated block (6 lines × 2) (Samples/SwiftJavaExtractFFMSampleApp/Sources/MySwiftLibrary/MySwiftStruct.swift)
  • Duplicated block (8 lines × 2) (Sources/SwiftExtract/SwiftTypes/SwiftParsedModuleSymbolTableBuilder.swift)
  • Duplicated block (8 lines × 4) (Sources/SwiftExtract/Logger.swift)
  • Duplicated block (9 lines × 2) (Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator.swift)
  • Duplicated block (9 lines × 2) (Sources/JExtractSwiftLib/JavaExtractDecider.swift)
  • FileTooLong: SwiftExtract/SwiftAnalysisVisitor.swift (Sources/SwiftExtract/SwiftAnalysisVisitor.swift)
  • …and 48 more

New (58)

  • Change coupling: SwiftSyntax+Extensions.swift ↔ Configuration.swift (Sources/JExtractSwiftLib/Convenience/SwiftSyntax+Extensions.swift)
  • Duplicated block (10 lines × 2) (Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaBindingsPrinting.swift)
  • Duplicated block (10 lines × 2) (Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift)
  • Duplicated block (14 lines × 2) (Sources/SwiftJava/JavaObject+MethodCalls.swift)
  • Duplicated block (4–8 lines × 3) (Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift)
  • Duplicated block (5 lines × 2) (Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaBindingsPrinting.swift)
  • Duplicated block (5 lines × 3) (Sources/JExtractSwiftLib/FFM/CDeclLowering/FFMSwift2JavaGenerator+FunctionLowering.swift)
  • Duplicated block (6 lines × 2) (Samples/SwiftJavaExtractFFMSampleApp/Sources/MySwiftLibrary/MySwiftStruct.swift)
  • Duplicated block (9 lines × 2) (Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator.swift)
  • Edited copies of one member (3 members, 10+ corresponding lines) (Sources/SwiftJava/BridgedValues/JavaBoxing.swift)
  • Edited copies of one member (3 members, 6+ corresponding lines) (Sources/SwiftJava/BridgedValues/JobjectBridge.swift)
  • Edited copies of one member (3 members, 9+ corresponding lines) (Sources/CodePrinting/CodePrinter+Java.swift)
  • Edited copies of one member (4 members, 4+ corresponding lines) (Samples/SwiftAndJavaJarFFMSampleLib/Sources/MySwiftLibrary/MySwiftLibrary.swift)
  • Edited copies of one member (4 members, 5+ corresponding lines) (Sources/SwiftJava/BridgedValues/SwiftDictionaryMap+JNI.swift)
  • Edited copies of one member (4 members, 7+ corresponding lines) (Sources/SwiftJava/BridgedValues/JavaBoxing.swift)
  • Edited copies of one member (5 members, 15+ corresponding lines) (Sources/SwiftJava/SwiftObjects.swift)
  • Edited copies of one member (8 members, 22+ corresponding lines) (SwiftKitCore/src/main/java/org/swift/swiftkit/core/tuple/Tuple17.java)
  • Edited copies of one member (8 members, 3+ corresponding lines) (SwiftKitCore/src/main/java/org/swift/swiftkit/core/tuple/Tuple17.java)
  • Edited copies of one member (8 members, 3+ corresponding lines) (SwiftKitCore/src/main/java/org/swift/swiftkit/core/tuple/Tuple17.java)
  • Edited copy of a member (10 corresponding lines) (SwiftKitCore/src/main/java/org/swift/swiftkit/core/CallTraces.java)
  • …and 38 more

Changes since last survey

  • 5 commits — 4 feature/other, 1 fixes

By area

  • (root) — 1 commit
  • Samples/SwiftJavaExtractJNISampleApp — 1 commit
  • Sources/JExtractSwiftLib — 1 commit
  • Sources/SwiftExtract — 1 commit
  • Sources/SwiftJavaDocumentation — 1 commit

Notable commits

  • fix: jextract/jni: Fix protocol parameter helper naming (#960)
  • change: Document main actor execution in Java hosts (#956)
  • change: Pin swift-collections below 1.7.0 to keep Swift 6.1 building (#958)
  • change: Split out SwiftExtract into swift-binding-generator-core (#957)
  • change: jextract: keep Swift names that are Java keywords out of generated Java (#954)

Architecture

  • Unchanged — 0 containers · 3 contexts · 1 edges

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

swiftlang/swift-java was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 15 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 793e154159827b7f9fc9dec3dbd95a8251257e0f — the exact code this score is about.
  • Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-3c33c1882dc1.