Skip to content

Commit e885144

Browse files
committed
fix protocol threading
1 parent bf5ca01 commit e885144

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Sources/SwiftJava/JavaObject+Inheritance.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ extension AnyJavaObject {
2525
guard let this: jobject = javaThisOptional else {
2626
return nil
2727
}
28+
let environment = try! JavaVirtualMachine.shared().environment()
2829

29-
return try? otherClass.withJNIClass(in: javaEnvironment) { otherJavaClass in
30-
if javaEnvironment.interface.IsInstanceOf(javaEnvironment, this, otherJavaClass) == 0 {
30+
return try? otherClass.withJNIClass(in: environment) { otherJavaClass in
31+
if environment.interface.IsInstanceOf(environment, this, otherJavaClass) == 0 {
3132
return nil
3233
}
3334

Sources/SwiftJavaRuntimeSupport/generated/JavaJNISwiftInstance.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
import SwiftJava
1616

1717
@JavaInterface("org.swift.swiftkit.core.JNISwiftInstance")
18-
public struct JavaJNISwiftInstance {
18+
public struct JavaJNISwiftInstance: AnyJavaObjectWithCustomClassLoader {
1919
@JavaMethod("$memoryAddress")
2020
public func memoryAddress() -> Int64
21+
22+
public static func getJavaClassLoader(in environment: JNIEnvironment) throws -> JavaClassLoader! {
23+
JNI.shared.applicationClassLoader
24+
}
2125
}

0 commit comments

Comments
 (0)