Skip to content

Conversation

@madsodgaard
Copy link
Contributor

Converts SwiftJava to a dynamic lib, that will be loaded in the JExtract libs. This will always us to tap into JNI_OnLoad to get the shared JVM, and also cache the application class loader, so that we can use that as a fallback in the withJNIClass, if for example running on a native thread.

Resolves #419

Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

// Called by generated code, and not automatically by Java.
public func _JNI_OnLoad(_ javaVM: JavaVMPointer, _ reserved: UnsafeMutableRawPointer) {
@_cdecl("JNI_OnLoad")
func SwiftJava_JNI_OnLoad(javaVM: JavaVMPointer, reserved: UnsafeMutableRawPointer) -> jint {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need this "lower", in a lib that does not have macros?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note, we'll do that later

@ktoso ktoso merged commit 0685f55 into swiftlang:main Dec 11, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

swift-java does not work on Android API 28-30, due to missing JavaVM JNI symbols

2 participants