Skip to content

jextract: Use fully qualified java.lang.String to avoid shadowing#696

Merged
ktoso merged 2 commits intoswiftlang:mainfrom
sidepelican:fix_string_type
Apr 10, 2026
Merged

jextract: Use fully qualified java.lang.String to avoid shadowing#696
ktoso merged 2 commits intoswiftlang:mainfrom
sidepelican:fix_string_type

Conversation

@sidepelican
Copy link
Copy Markdown
Contributor

When generating Java code for next Swift type a nested Java record named String is created.

public enum MyEnum {
    ...
    case string(String)
}
public final class JSON implements JNISwiftInstance {
  public record String(java.lang.String arg0) implements Case {
    record _NativeParameters(java.lang.String arg0) {}
  }

This causes the standard java.lang.String to be shadowed within that scope, leading to uncompilable source code where the generator expects the standard JDK String but finds the newly generated one instead.

To prevent this, the generator now uses the fully qualified name.

Note

This applies to other types as well (such as AtomicBoolean), but I am only addressing String in this PR for now.

@sidepelican sidepelican requested a review from ktoso as a code owner April 10, 2026 08:33
@ktoso
Copy link
Copy Markdown
Collaborator

ktoso commented Apr 10, 2026

Lgtm!

@ktoso ktoso merged commit bf7ac4e into swiftlang:main Apr 10, 2026
64 checks passed
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.

2 participants