From 3eeb5a91808faa8c82f821d6a41f9493951d201c Mon Sep 17 00:00:00 2001 From: Iceman Date: Tue, 17 Feb 2026 15:33:23 +0900 Subject: [PATCH 1/4] Include toString function generation in the common method generation path --- ...Swift2JavaGenerator+FunctionLowering.swift | 4 ++ ...MSwift2JavaGenerator+JavaTranslation.swift | 2 +- Sources/JExtractSwiftLib/ImportedDecls.swift | 4 +- ...t2JavaGenerator+JavaBindingsPrinting.swift | 25 ---------- ...ISwift2JavaGenerator+JavaTranslation.swift | 2 +- ...ift2JavaGenerator+SwiftThunkPrinting.swift | 48 ++----------------- .../JExtractSwiftLib/Swift2JavaVisitor.swift | 42 ++++++++++++++++ .../JNI/JNIToStringTests.swift | 17 ++++--- 8 files changed, 63 insertions(+), 81 deletions(-) diff --git a/Sources/JExtractSwiftLib/FFM/CDeclLowering/FFMSwift2JavaGenerator+FunctionLowering.swift b/Sources/JExtractSwiftLib/FFM/CDeclLowering/FFMSwift2JavaGenerator+FunctionLowering.swift index 32757a79..bab7540f 100644 --- a/Sources/JExtractSwiftLib/FFM/CDeclLowering/FFMSwift2JavaGenerator+FunctionLowering.swift +++ b/Sources/JExtractSwiftLib/FFM/CDeclLowering/FFMSwift2JavaGenerator+FunctionLowering.swift @@ -1016,6 +1016,10 @@ extension LoweredFunctionSignature { let parameters = argumentsWithoutNewValue.map { $0.description }.joined(separator: ", ") resultExpr = "\(callee)[\(raw: parameters)] = \(newValueArgument)" + case .toString: + resultExpr = "String(describing: \(callee))" + case .toDebugString: + resultExpr = "String(reflecting: \(callee))" } // Lower the result. diff --git a/Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaTranslation.swift b/Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaTranslation.swift index cf32a430..5ea3b898 100644 --- a/Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaTranslation.swift +++ b/Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaTranslation.swift @@ -160,7 +160,7 @@ extension FFMSwift2JavaGenerator { switch decl.apiKind { case .getter, .subscriptGetter: decl.javaGetterName case .setter, .subscriptSetter: decl.javaSetterName - case .function, .initializer, .enumCase: decl.name + case .function, .initializer, .enumCase, .toString, .toDebugString: decl.name } // Signature. diff --git a/Sources/JExtractSwiftLib/ImportedDecls.swift b/Sources/JExtractSwiftLib/ImportedDecls.swift index 7bb2f041..e09e80fc 100644 --- a/Sources/JExtractSwiftLib/ImportedDecls.swift +++ b/Sources/JExtractSwiftLib/ImportedDecls.swift @@ -25,6 +25,8 @@ package enum SwiftAPIKind { case enumCase case subscriptGetter case subscriptSetter + case toString + case toDebugString } /// Describes a Swift nominal type (e.g., a class, struct, enum) that has been @@ -182,7 +184,7 @@ public final class ImportedFunc: ImportedDecl, CustomStringConvertible { case .getter: "getter:" case .setter: "setter:" case .enumCase: "case:" - case .function, .initializer: "" + case .function, .initializer, .toString, .toDebugString: "" case .subscriptGetter: "subscriptGetter:" case .subscriptSetter: "subscriptSetter:" } diff --git a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift index ffc5fffd..87a5d358 100644 --- a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift +++ b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift @@ -267,9 +267,6 @@ extension JNISwift2JavaGenerator { printer.println() } - printToStringMethods(&printer, decl) - printer.println() - printSpecificTypeHelpers(&printer, decl) printTypeMetadataAddressFunction(&printer, decl) @@ -294,28 +291,6 @@ extension JNISwift2JavaGenerator { } } - private func printToStringMethods(_ printer: inout CodePrinter, _ decl: ImportedNominalType) { - printer.printBraceBlock("public String toString()") { printer in - printer.print( - """ - return $toString(this.$memoryAddress()); - """ - ) - } - printer.print("private static native java.lang.String $toString(long selfPointer);") - - printer.println() - - printer.printBraceBlock("public String toDebugString()") { printer in - printer.print( - """ - return $toDebugString(this.$memoryAddress()); - """ - ) - } - printer.print("private static native java.lang.String $toDebugString(long selfPointer);") - } - private func printHeader(_ printer: inout CodePrinter) { printer.print( """ diff --git a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift index 436956d2..e78d996d 100644 --- a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift +++ b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift @@ -208,7 +208,7 @@ extension JNISwift2JavaGenerator { switch decl.apiKind { case .getter, .subscriptGetter: decl.javaGetterName case .setter, .subscriptSetter: decl.javaSetterName - case .function, .initializer, .enumCase: decl.name + case .function, .initializer, .enumCase, .toString, .toDebugString: decl.name } // Swift -> Java diff --git a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift index c12080ee..70068c57 100644 --- a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift +++ b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift @@ -271,7 +271,6 @@ extension JNISwift2JavaGenerator { printer.println() } - printToStringMethods(&printer, type) printSpecificTypeThunks(&printer, type) printTypeMetadataAddressThunk(&printer, type) printer.println() @@ -286,49 +285,6 @@ extension JNISwift2JavaGenerator { try printSwiftInterfaceWrapper(&printer, protocolWrapper) } - private func printToStringMethods(_ printer: inout CodePrinter, _ type: ImportedNominalType) { - let selfPointerParam = JavaParameter(name: "selfPointer", type: .long) - let parentName = type.qualifiedName - - printCDecl( - &printer, - javaMethodName: "$toString", - parentName: type.swiftNominal.qualifiedName, - parameters: [ - selfPointerParam - ], - resultType: .javaLangString - ) { printer in - let selfVar = self.printSelfJLongToUnsafeMutablePointer(&printer, swiftParentName: parentName, selfPointerParam) - - printer.print( - """ - return String(describing: \(selfVar).pointee).getJNIValue(in: environment) - """ - ) - } - - printer.println() - - printCDecl( - &printer, - javaMethodName: "$toDebugString", - parentName: type.swiftNominal.qualifiedName, - parameters: [ - selfPointerParam - ], - resultType: .javaLangString - ) { printer in - let selfVar = self.printSelfJLongToUnsafeMutablePointer(&printer, swiftParentName: parentName, selfPointerParam) - - printer.print( - """ - return String(reflecting: \(selfVar).pointee).getJNIValue(in: environment) - """ - ) - } - } - private func printEnumDiscriminator(_ printer: inout CodePrinter, _ type: ImportedNominalType) { let selfPointerParam = JavaParameter(name: "selfPointer", type: .long) printCDecl( @@ -657,6 +613,10 @@ extension JNISwift2JavaGenerator { let parameters = argumentsWithoutNewValue.joined(separator: ", ") result = "\(callee)[\(parameters)] = \(newValueArgument)" + case .toString: + result = "String(describing: \(callee))" + case .toDebugString: + result = "String(reflecting: \(callee))" } // Lower the result. diff --git a/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift b/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift index ff6295bb..ad05d5d5 100644 --- a/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift +++ b/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift @@ -85,6 +85,8 @@ final class Swift2JavaVisitor { for memberItem in node.memberBlock.members { self.visit(decl: memberItem.decl, in: importedNominalType, sourceFilePath: sourceFilePath) } + + self.synthesizeToStringMethods(in: importedNominalType) } func visit( @@ -405,6 +407,46 @@ final class Swift2JavaVisitor { } } } + + private func synthesizeToStringMethods(in imported: ImportedNominalType) { + switch imported.swiftNominal.kind { + case .actor, .class, .enum, .struct: + break + case .protocol: + return + } + + let knownTypes = SwiftKnownTypes(symbolTable: translator.symbolTable) + let toStringFunctionSignature = SwiftFunctionSignature( + selfParameter: .instance(SwiftParameter(convention: .byValue, type: imported.swiftType)), + parameters: [], + result: SwiftResult(convention: .direct, type: knownTypes.string), + effectSpecifiers: [], + genericParameters: [], + genericRequirements: [] + ) + + func makeToStringFunc(name: String, kind: SwiftAPIKind) -> ImportedFunc { + return ImportedFunc( + module: translator.swiftModuleName, + swiftDecl: DeclSyntax("func \(raw: name)() -> String"), + name: name, + apiKind: kind, + functionSignature: toStringFunctionSignature + ) + } + + if !imported.methods.contains(where: { + $0.name == "toString" && $0.functionSignature == toStringFunctionSignature + }) { + imported.methods.append(makeToStringFunc(name: "toString", kind: .toString)) + } + if !imported.methods.contains(where: { + $0.name == "toDebugString" && $0.functionSignature == toStringFunctionSignature + }) { + imported.methods.append(makeToStringFunc(name: "toDebugString", kind: .toDebugString)) + } + } } extension DeclSyntaxProtocol where Self: WithModifiersSyntax & WithAttributesSyntax { diff --git a/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift b/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift index e67561b8..95322686 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift @@ -32,12 +32,10 @@ struct JNIToStringTests { detectChunkByInitialLines: 1, expectedChunks: [ """ - public String toString() { - return $toString(this.$memoryAddress()); + public java.lang.String toString() { + return MyType.$toString(this.$memoryAddress()); } - """, - """ - private static native java.lang.String $toString(long selfPointer); + private static native java.lang.String $toString(long self); """, ] ) @@ -53,7 +51,7 @@ struct JNIToStringTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyType__00024toString__J") - public func Java_com_example_swift_MyType__00024toString__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jstring? { + public func Java_com_example_swift_MyType__00024toString__J(environment: UnsafeMutablePointer!, thisClass: jclass, self: jlong) -> jstring? { ... return String(describing: self$.pointee).getJNIValue(in: environment) } @@ -71,9 +69,10 @@ struct JNIToStringTests { detectChunkByInitialLines: 1, expectedChunks: [ """ - public String toDebugString() { - return $toDebugString(this.$memoryAddress()); + public java.lang.String toDebugString() { + return MyType.$toDebugString(this.$memoryAddress()); } + private static native java.lang.String $toDebugString(long self); """ ] ) @@ -89,7 +88,7 @@ struct JNIToStringTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyType__00024toDebugString__J") - public func Java_com_example_swift_MyType__00024toDebugString__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jstring? { + public func Java_com_example_swift_MyType__00024toDebugString__J(environment: UnsafeMutablePointer!, thisClass: jclass, self: jlong) -> jstring? { ... return String(reflecting: self$.pointee).getJNIValue(in: environment) } From 24097b6ada17d8a04460f3c60e636b049561231e Mon Sep 17 00:00:00 2001 From: Iceman Date: Tue, 17 Feb 2026 17:52:20 +0900 Subject: [PATCH 2/4] swift format --- Sources/JExtractSwiftLib/Swift2JavaVisitor.swift | 2 +- Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift b/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift index ad05d5d5..f66dba3d 100644 --- a/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift +++ b/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift @@ -427,7 +427,7 @@ final class Swift2JavaVisitor { ) func makeToStringFunc(name: String, kind: SwiftAPIKind) -> ImportedFunc { - return ImportedFunc( + ImportedFunc( module: translator.swiftModuleName, swiftDecl: DeclSyntax("func \(raw: name)() -> String"), name: name, diff --git a/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift b/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift index 95322686..36476111 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift @@ -36,7 +36,7 @@ struct JNIToStringTests { return MyType.$toString(this.$memoryAddress()); } private static native java.lang.String $toString(long self); - """, + """ ] ) } From bef0d3b9d416d6e88490c9bcbe7f35fae68638e2 Mon Sep 17 00:00:00 2001 From: Iceman Date: Thu, 19 Feb 2026 10:32:23 +0900 Subject: [PATCH 3/4] case synthesizedFunction(SynthesizedAPI) --- .../FFMSwift2JavaGenerator+FunctionLowering.swift | 12 ++++++++---- .../FFM/FFMSwift2JavaGenerator+JavaTranslation.swift | 2 +- Sources/JExtractSwiftLib/ImportedDecls.swift | 12 ++++++++---- .../JNI/JNISwift2JavaGenerator+JavaTranslation.swift | 2 +- .../JNISwift2JavaGenerator+SwiftThunkPrinting.swift | 12 ++++++++---- Sources/JExtractSwiftLib/Swift2JavaVisitor.swift | 4 ++-- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Sources/JExtractSwiftLib/FFM/CDeclLowering/FFMSwift2JavaGenerator+FunctionLowering.swift b/Sources/JExtractSwiftLib/FFM/CDeclLowering/FFMSwift2JavaGenerator+FunctionLowering.swift index bab7540f..9d53b8b5 100644 --- a/Sources/JExtractSwiftLib/FFM/CDeclLowering/FFMSwift2JavaGenerator+FunctionLowering.swift +++ b/Sources/JExtractSwiftLib/FFM/CDeclLowering/FFMSwift2JavaGenerator+FunctionLowering.swift @@ -993,6 +993,14 @@ extension LoweredFunctionSignature { .joined(separator: ", ") resultExpr = "\(callee)(\(raw: arguments))" + case .synthesizedFunction(let function): + switch function { + case .toString: + resultExpr = "String(describing: \(callee))" + case .toDebugString: + resultExpr = "String(reflecting: \(callee))" + } + case .getter: assert(paramExprs.isEmpty) resultExpr = callee @@ -1016,10 +1024,6 @@ extension LoweredFunctionSignature { let parameters = argumentsWithoutNewValue.map { $0.description }.joined(separator: ", ") resultExpr = "\(callee)[\(raw: parameters)] = \(newValueArgument)" - case .toString: - resultExpr = "String(describing: \(callee))" - case .toDebugString: - resultExpr = "String(reflecting: \(callee))" } // Lower the result. diff --git a/Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaTranslation.swift b/Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaTranslation.swift index 5ea3b898..5c7d8713 100644 --- a/Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaTranslation.swift +++ b/Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaTranslation.swift @@ -160,7 +160,7 @@ extension FFMSwift2JavaGenerator { switch decl.apiKind { case .getter, .subscriptGetter: decl.javaGetterName case .setter, .subscriptSetter: decl.javaSetterName - case .function, .initializer, .enumCase, .toString, .toDebugString: decl.name + case .function, .synthesizedFunction, .initializer, .enumCase: decl.name } // Signature. diff --git a/Sources/JExtractSwiftLib/ImportedDecls.swift b/Sources/JExtractSwiftLib/ImportedDecls.swift index e09e80fc..1879bc76 100644 --- a/Sources/JExtractSwiftLib/ImportedDecls.swift +++ b/Sources/JExtractSwiftLib/ImportedDecls.swift @@ -17,16 +17,20 @@ import SwiftSyntax /// Any imported (Swift) declaration protocol ImportedDecl: AnyObject {} -package enum SwiftAPIKind { +package enum SynthesizedAPI: Equatable { + case toString + case toDebugString +} + +package enum SwiftAPIKind: Equatable { case function + case synthesizedFunction(SynthesizedAPI) case initializer case getter case setter case enumCase case subscriptGetter case subscriptSetter - case toString - case toDebugString } /// Describes a Swift nominal type (e.g., a class, struct, enum) that has been @@ -184,7 +188,7 @@ public final class ImportedFunc: ImportedDecl, CustomStringConvertible { case .getter: "getter:" case .setter: "setter:" case .enumCase: "case:" - case .function, .initializer, .toString, .toDebugString: "" + case .function, .synthesizedFunction, .initializer: "" case .subscriptGetter: "subscriptGetter:" case .subscriptSetter: "subscriptSetter:" } diff --git a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift index e78d996d..fc0b0102 100644 --- a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift +++ b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift @@ -208,7 +208,7 @@ extension JNISwift2JavaGenerator { switch decl.apiKind { case .getter, .subscriptGetter: decl.javaGetterName case .setter, .subscriptSetter: decl.javaSetterName - case .function, .initializer, .enumCase, .toString, .toDebugString: decl.name + case .function, .synthesizedFunction, .initializer, .enumCase: decl.name } // Swift -> Java diff --git a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift index 70068c57..347d2024 100644 --- a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift +++ b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift @@ -579,6 +579,14 @@ extension JNISwift2JavaGenerator { .joined(separator: ", ") result = "\(tryClause)\(callee).\(decl.name)(\(downcallArguments))" + case .synthesizedFunction(let function): + switch function { + case .toString: + result = "String(describing: \(callee))" + case .toDebugString: + result = "String(reflecting: \(callee))" + } + case .enumCase: let downcallArguments = zip( decl.functionSignature.parameters, @@ -613,10 +621,6 @@ extension JNISwift2JavaGenerator { let parameters = argumentsWithoutNewValue.joined(separator: ", ") result = "\(callee)[\(parameters)] = \(newValueArgument)" - case .toString: - result = "String(describing: \(callee))" - case .toDebugString: - result = "String(reflecting: \(callee))" } // Lower the result. diff --git a/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift b/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift index f66dba3d..eef5d29e 100644 --- a/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift +++ b/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift @@ -439,12 +439,12 @@ final class Swift2JavaVisitor { if !imported.methods.contains(where: { $0.name == "toString" && $0.functionSignature == toStringFunctionSignature }) { - imported.methods.append(makeToStringFunc(name: "toString", kind: .toString)) + imported.methods.append(makeToStringFunc(name: "toString", kind: .synthesizedFunction(.toString))) } if !imported.methods.contains(where: { $0.name == "toDebugString" && $0.functionSignature == toStringFunctionSignature }) { - imported.methods.append(makeToStringFunc(name: "toDebugString", kind: .toDebugString)) + imported.methods.append(makeToStringFunc(name: "toDebugString", kind: .synthesizedFunction(.toDebugString))) } } } From b338b20ffcb56062a8e41861a90478e5ba6a18e9 Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Tue, 24 Feb 2026 12:27:53 +0900 Subject: [PATCH 4/4] dont change parameter name to self --- Sources/JExtractSwiftLib/Swift2JavaVisitor.swift | 2 +- Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift b/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift index eef5d29e..9d3a60dd 100644 --- a/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift +++ b/Sources/JExtractSwiftLib/Swift2JavaVisitor.swift @@ -418,7 +418,7 @@ final class Swift2JavaVisitor { let knownTypes = SwiftKnownTypes(symbolTable: translator.symbolTable) let toStringFunctionSignature = SwiftFunctionSignature( - selfParameter: .instance(SwiftParameter(convention: .byValue, type: imported.swiftType)), + selfParameter: .instance(SwiftParameter(convention: .byValue, parameterName: "selfPointer", type: imported.swiftType)), parameters: [], result: SwiftResult(convention: .direct, type: knownTypes.string), effectSpecifiers: [], diff --git a/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift b/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift index 36476111..45b67aca 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIToStringTests.swift @@ -35,7 +35,7 @@ struct JNIToStringTests { public java.lang.String toString() { return MyType.$toString(this.$memoryAddress()); } - private static native java.lang.String $toString(long self); + private static native java.lang.String $toString(long selfPointer); """ ] ) @@ -51,9 +51,9 @@ struct JNIToStringTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyType__00024toString__J") - public func Java_com_example_swift_MyType__00024toString__J(environment: UnsafeMutablePointer!, thisClass: jclass, self: jlong) -> jstring? { + public func Java_com_example_swift_MyType__00024toString__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jstring? { ... - return String(describing: self$.pointee).getJNIValue(in: environment) + return String(describing: selfPointer$.pointee).getJNIValue(in: environment) } """ ] @@ -72,7 +72,7 @@ struct JNIToStringTests { public java.lang.String toDebugString() { return MyType.$toDebugString(this.$memoryAddress()); } - private static native java.lang.String $toDebugString(long self); + private static native java.lang.String $toDebugString(long selfPointer); """ ] ) @@ -88,9 +88,9 @@ struct JNIToStringTests { expectedChunks: [ """ @_cdecl("Java_com_example_swift_MyType__00024toDebugString__J") - public func Java_com_example_swift_MyType__00024toDebugString__J(environment: UnsafeMutablePointer!, thisClass: jclass, self: jlong) -> jstring? { + public func Java_com_example_swift_MyType__00024toDebugString__J(environment: UnsafeMutablePointer!, thisClass: jclass, selfPointer: jlong) -> jstring? { ... - return String(reflecting: self$.pointee).getJNIValue(in: environment) + return String(reflecting: selfPointer$.pointee).getJNIValue(in: environment) } """ ]