Open lokesh-tr opened 1 month ago
This is documented more in https://github.com/swiftlang/swift-java/pull/14
Long story short: we'll support both eventually, 22+ with the panama mode, and old versions with just JNI. JavaKit is just JNI and would work with old Java versions.
We need to make the build "smart enough" to survive this eventually.
Today, for ease of development / bootstrapping we're just requiring the latest supported JDK which has Panama. In the end the required JDK will depend on which feature you're intending to use.
We're not at a phase of "cleanup and publishing" yet, so yes, for now we're just developing with the latest JDK.
Long story short: we'll support both eventually, 22+ with the panama mode, and old versions with just JNI. JavaKit is just JNI and would work with old Java versions.
I expected this would be the case as well.
We're not at a phase of "cleanup and publishing" yet, so yes, for now we're just developing with the latest JDK.
I totally understand that, I just think that eventhough we are in early stages of development, the project should be such that, someone can follow the instructions in the Guide and be like "wow, this works" and the JDK requirements not being specified beforehand may not let them reach that point.
For example, running the tests as suggested in README failed for me. The reason being that I'm using a x86_64
device. It would have been nice if this had been specified in the README itself like "This project is under development and for the sake of it, we are currently using JDK 22 & arm64
device"
Most people will be happy to see the code run and fail than to not see the code run at all due to environment setup issues.
This is documented more in https://github.com/swiftlang/swift-java/pull/14
That's great
This is due to the fact that we hardcoded the
vmArgs.version
toJNI_VERSION_21
while instantiating aJavaVirtualMachine
object.
I don't think anything in JavaKit or the Java2Swift direction needs JDK 21. Setting the meta-points of the discussion aside, I think we can replace this with an older constant after a quick review of whether we're using anything that was introduced into newer versions of the JDK.
With https://github.com/swiftlang/swift-java/pull/50, we can support much older JDK versions. I set it at 1.6 (the oldest JNI version that supports the APIs we need).
Currently the
jextract-swift
section of theUSER_GUIDE
tells us that it needs JDK 22 to utilise "Project Panama".Upon further inspection, I realised that the
Java2Swift
Program doesn't compile at all if the JDK version is lesser than 21. This is due to the fact that we hardcoded thevmArgs.version
toJNI_VERSION_21
while instantiating aJavaVirtualMachine
object.This
JNI_VERSION_21
is a preprocessor constant which is only available in JDK 21 or later.If this is the intended behaviour, It will be better to update the
USER_GUIDE
to let people know thatJava2Swift
will need a JDK that is 21 or later. However, if this is not the intended behaviour, then replacing the hardcoded JNI version with a JNI version which corresponds to the user's JDK would be better.I'm not an expert in this context, but making an assumption that a lot of current enterprises (who would like to move their tech stack from JVM to Swift) need not be running their software in JDK 21 or later would be more realistic. Thus, I believe trying to support older JDKs instead of supporting only JDK 21 or later (unless mandatory such as "Project Panama") will be better for this project. Feel free to correct me if I'm wrong.
Edit: Realised the gradle files also specify JDK 22 to be a requirement.