swiftlang / swiftlang/swift-java

Consider various @Nullable @Nonnull annotations when importing types

Open
#130 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature:wrap-java mode:jni
Dominant language
Swift
Stars
1.2k
Forks
123
Avg merge
1d 7h
Merged PRs (30d)
16

Description

While "dormant" some project do use the JSR-305 annotations, and one of them is https://www.javadoc.io/static/com.google.code.findbugs/jsr305/3.0.2/javax/annotation/Nonnull.html and Nullable

This is something that can inform how we import values to Swift in JavaKit.

The nullability ones are quite messy and there's many libraries which "have their own" since the JSR never made it into the JDK. So we should just match "by name" if an attribute is called "nullable" "nonnull" and similar names.

JSR-305 ones are:

We might care about jspecify, this is new to me but seems it's folks coming together to revive the effort:

names are NonNull Nullable and NullMarked NullUnmarked to basically say if some region was annotated at all or not.

Findbugs which is a tool "most people use" supports the JSR305 ones.

Micrometer ones exist but would be weird I guess to rely on them; Nullable is the same, but it has a few more:

So we can either list a bunch of known types or just match by the attribute name - they mostly all have the same semantics

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating JavaKit's type-import and nullability handling. Review the JSR-305, JSpecify, and Micrometer annotation names listed in the issue, then determine how their semantics should inform Swift imports. Done means the chosen annotation strategy is implemented consistently and its behavior is verified by the relevant existing checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, swift
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.