File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1186,13 +1186,16 @@ extension JNISwift2JavaGenerator {
11861186 // FIXME: More accurate determination of whether the result is direct or indirect
11871187 if elementResult. outParameters. isEmpty {
11881188 // Convert direct result to indirect result.
1189- // For class types (nominal types), the JNI native representation is 'long'
1190- // (a memory address), not the wrapper class type
1189+ // For most class types (Swift wrapper classes), the JNI native representation
1190+ // is 'long' (a memory address). However, String is a native JNI reference
1191+ // type and must keep its original type so the out-parameter array matches
1192+ // the native method signature (String[] not long[])
11911193 let nativeElementType : JavaType
1192- switch elementResult. javaType {
1193- case . class:
1194+ if elementResult. javaType. isString {
1195+ nativeElementType = elementResult. javaType
1196+ } else if case . class = elementResult. javaType {
11941197 nativeElementType = . long
1195- default :
1198+ } else {
11961199 nativeElementType = elementResult. javaType
11971200 }
11981201 let arrayType : JavaType = . array( nativeElementType)
Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ struct JNIGenericCombinationTests {
234234 expectedChunks: [
235235 """
236236 public static org.swift.swiftkit.core.tuple.Tuple2<java.lang.String, java.lang.Long> takeValues(org.swift.swiftkit.core.tuple.Tuple2<MyID<java.lang.String>, MyID<java.lang.Long>> tuple) {
237- long [] result_0$ = new long [1];
237+ java.lang.String [] result_0$ = new java.lang.String [1];
238238 long[] result_1$ = new long[1];
239239 SwiftModule.$takeValues(tuple.$0.$memoryAddress(), tuple.$1.$memoryAddress(), result_0$, result_1$);
240240 return new org.swift.swiftkit.core.tuple.Tuple2<java.lang.String, java.lang.Long>(result_0$[0], result_1$[0]);
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ struct JNITupleTests {
3434 """
3535 public static org.swift.swiftkit.core.tuple.Tuple2<java.lang.Long, java.lang.String> returnPair() {
3636 long[] result_0$ = new long[1];
37- long [] result_1$ = new long [1];
37+ java.lang.String [] result_1$ = new java.lang.String [1];
3838 SwiftModule.$returnPair(result_0$, result_1$);
3939 return new org.swift.swiftkit.core.tuple.Tuple2<java.lang.Long, java.lang.String>(result_0$[0], result_1$[0]);
4040 }
You can’t perform that action at this time.
0 commit comments