@@ -311,4 +311,54 @@ struct JNIArrayTest {
311311 ]
312312 )
313313 }
314+
315+ // ==== -----------------------------------------------------------------------
316+ // MARK: Tuples with array elements
317+
318+ @Test ( " Import: () -> (name: [UInt8], another: [UInt8]) (Java) " )
319+ func tupleByteArrays_java( ) throws {
320+ try assertOutput (
321+ input: " public func namedByteArrayTuple() -> (name: [UInt8], another: [UInt8]) {} " ,
322+ . jni,
323+ . java,
324+ detectChunkByInitialLines: 1 ,
325+ expectedChunks: [
326+ """
327+ @Unsigned
328+ public static LabeledTuple_namedByteArrayTuple_name_another<byte[], byte[]> namedByteArrayTuple() {
329+ byte[][] result_0$ = new byte[1][];
330+ byte[][] result_1$ = new byte[1][];
331+ SwiftModule.$namedByteArrayTuple(result_0$, result_1$);
332+ return new LabeledTuple_namedByteArrayTuple_name_another<byte[], byte[]>(result_0$[0], result_1$[0]);
333+ }
334+ """ ,
335+ """
336+ private static native void $namedByteArrayTuple(byte[][] result_0$, byte[][] result_1$);
337+ """ ,
338+ ]
339+ )
340+ }
341+
342+ @Test ( " Import: () -> (name: [UInt8], another: [UInt8]) (Swift) " )
343+ func tupleByteArrays_swift( ) throws {
344+ try assertOutput (
345+ input: " public func namedByteArrayTuple() -> (name: [UInt8], another: [UInt8]) {} " ,
346+ . jni,
347+ . swift,
348+ detectChunkByInitialLines: 1 ,
349+ expectedChunks: [
350+ """
351+ @_cdecl( " Java_com_example_swift_SwiftModule__00024namedByteArrayTuple___3_3B_3_3B " )
352+ public func Java_com_example_swift_SwiftModule__00024namedByteArrayTuple___3_3B_3_3B(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, result_0$: jobjectArray?, result_1$: jobjectArray?) {
353+ let tupleResult$ = SwiftModule.namedByteArrayTuple()
354+ let element_0_jni$ = tupleResult$.name.getJNILocalRefValue(in: environment)
355+ environment.interface.SetObjectArrayElement(environment, result_0$, 0, element_0_jni$)
356+ let element_1_jni$ = tupleResult$.another.getJNILocalRefValue(in: environment)
357+ environment.interface.SetObjectArrayElement(environment, result_1$, 0, element_1_jni$)
358+ return
359+ }
360+ """
361+ ]
362+ )
363+ }
314364}
0 commit comments