@@ -33,7 +33,7 @@ struct JNIVariablesTests {
3333 set { }
3434 }
3535 public var someBoolean: Bool
36- public let isBoolean: Bool
36+ public var isBoolean: Bool
3737 }
3838 """
3939
@@ -372,7 +372,7 @@ struct JNIVariablesTests {
372372 }
373373
374374 @Test
375- func boolean_swiftThunks ( ) throws {
375+ func someBoolean_swiftThunks ( ) throws {
376376 try assertOutput (
377377 input: membersSource,
378378 . jni,
@@ -404,4 +404,87 @@ struct JNIVariablesTests {
404404 ]
405405 )
406406 }
407+
408+ @Test
409+ func isBoolean_javaBindings( ) throws {
410+ try assertOutput (
411+ input: membersSource,
412+ . jni,
413+ . java,
414+ detectChunkByInitialLines: 8 ,
415+ expectedChunks: [
416+ """
417+ /**
418+ * Downcall to Swift:
419+ * {@snippet lang=swift :
420+ * public var isBoolean: Bool
421+ * }
422+ */
423+ public boolean isBoolean() {
424+ long self$ = this.$memoryAddress();
425+ return MyClass.$isBoolean(self$);
426+ }
427+ """ ,
428+ """
429+ /**
430+ * Downcall to Swift:
431+ * {@snippet lang=swift :
432+ * public var isBoolean: Bool
433+ * }
434+ */
435+ public void setBoolean(boolean newValue) {
436+ long self$ = this.$memoryAddress();
437+ MyClass.$setBoolean(newValue, self$);
438+ }
439+ """ ,
440+ """
441+ private static native boolean $isBoolean(long selfPointer);
442+ """ ,
443+ """
444+ private static native void $setBoolean(boolean newValue, long selfPointer);
445+ """
446+ ]
447+ )
448+ }
449+
450+ @Test
451+ func isBoolean_swiftThunks( ) throws {
452+ try assertOutput (
453+ input: membersSource,
454+ . jni,
455+ . swift,
456+ detectChunkByInitialLines: 1 ,
457+ expectedChunks: [
458+ """
459+ @_cdecl( " Java_com_example_swift_MyClass__00024isBoolean__J " )
460+ func Java_com_example_swift_MyClass__00024isBoolean__J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, selfPointer: jlong) -> jboolean {
461+ guard let env$ = environment else {
462+ fatalError( " Missing JNIEnv in downcall to \\ (#function) " )
463+ }
464+ assert(selfPointer != 0, " selfPointer memory address was null " )
465+ let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
466+ guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
467+ fatalError( " self memory address was null in call to \\ (#function)! " )
468+ }
469+ let result = self$.pointee.isBoolean
470+ return result.getJNIValue(in: environment)
471+ }
472+ """ ,
473+ """
474+ @_cdecl( " Java_com_example_swift_MyClass__00024setBoolean__ZJ " )
475+ func Java_com_example_swift_MyClass__00024setBoolean__ZJ(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, newValue: jboolean, selfPointer: jlong) {
476+ guard let env$ = environment else {
477+ fatalError( " Missing JNIEnv in downcall to \\ (#function) " )
478+ }
479+ assert(selfPointer != 0, " selfPointer memory address was null " )
480+ let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
481+ guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
482+ fatalError( " self memory address was null in call to \\ (#function)! " )
483+ }
484+ self$.pointee.isBoolean = Bool(fromJNI: newValue, in: environment!)
485+ }
486+ """
487+ ]
488+ )
489+ }
407490}
0 commit comments