Skip to content

Commit 485ea4c

Browse files
committed
cleanup cache on jni unload
1 parent e492e45 commit 485ea4c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Samples/JExtractJNISampleApp/src/test/java/com/example/swift/VehicleEnumTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void getAsMotorbike() {
117117
assertEquals("Yamaha", motorbike.arg0());
118118
assertEquals(750, motorbike.horsePower());
119119
assertEquals(OptionalInt.empty(), motorbike.helmets());
120-
120+
121121
vehicle = Vehicle.motorbike("Yamaha", 750, OptionalInt.of(2), arena);
122122
motorbike = vehicle.getAsMotorbike().orElseThrow();
123123
assertEquals(OptionalInt.of(2), motorbike.helmets());

Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ extension JNISwift2JavaGenerator {
9898
}
9999
}
100100

101+
printer.println()
102+
printer.print(#"@_cdecl("JNI_OnUnload")"#)
103+
printer.printBraceBlock("func JNI_OnUnload(javaVM: UnsafeMutablePointer<JavaVM?>!, reserved: UnsafeMutableRawPointer!)") { printer in
104+
printer.print("JNICaches.cleanup()")
105+
}
106+
101107
let fileName = "\(self.swiftModuleName)+JNICaches.swift"
102108

103109
if let outputFile = try printer.writeContents(

0 commit comments

Comments
 (0)