@@ -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
@@ -463,7 +463,7 @@ struct JNIVariablesTests {
463463 /**
464464 * Downcall to Swift:
465465 * {@snippet lang=swift :
466- * public let isBoolean: Bool
466+ * public var isBoolean: Bool
467467 * }
468468 */
469469 public boolean isBoolean() {
@@ -472,8 +472,23 @@ struct JNIVariablesTests {
472472 }
473473 """ ,
474474 """
475+ /**
476+ * Downcall to Swift:
477+ * {@snippet lang=swift :
478+ * public var isBoolean: Bool
479+ * }
480+ */
481+ public void setBoolean(boolean newValue) {
482+ long self$ = this.$memoryAddress();
483+ MyClass.$setBoolean(newValue, self$);
484+ }
485+ """ ,
486+ """
475487 private static native boolean $isBoolean(long selfPointer);
476488 """ ,
489+ """
490+ private static native void $setBoolean(boolean newValue, long selfPointer);
491+ """
477492 ]
478493 )
479494 }
@@ -501,6 +516,20 @@ struct JNIVariablesTests {
501516 return result.getJNIValue(in: environment)
502517 }
503518 """ ,
519+ """
520+ @_cdecl( " Java_com_example_swift_MyClass__00024setBoolean__ZJ " )
521+ func Java_com_example_swift_MyClass__00024setBoolean__ZJ(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, newValue: jboolean, selfPointer: jlong) {
522+ guard let env$ = environment else {
523+ fatalError( " Missing JNIEnv in downcall to \\ (#function) " )
524+ }
525+ assert(selfPointer != 0, " selfPointer memory address was null " )
526+ let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
527+ guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
528+ fatalError( " self memory address was null in call to \\ (#function)! " )
529+ }
530+ self$.pointee.isBoolean = Bool(fromJNI: newValue, in: environment!)
531+ }
532+ """
504533 ]
505534 )
506535 }
0 commit comments