Skip to content

Commit

Permalink
fix: version detection on lts gvm releases
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Jan 26, 2024
1 parent 0dfa0ac commit b5691f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ import elide.runtime.core.internals.graalvm.GraalVMRuntime.Companion.VARIANT_NAT
}

// running on GraalVM JVM (e.g. 20.0.2+9-jvmci-23.0-b14)
if (source.contains("jvmci")) source.split("-").getOrNull(2)?.let { jvm ->
return Version.parse(jvm)
val tag = source.lowercase().trim()
if (source.contains("jvmci")) {
// check for LTS version tag, for example:
// `21.0.2+13-LTS-jvmci-23.1-b30`
val index = if (tag.contains("lts")) 3 else 2
source.split("-").getOrNull(index)?.let { jvm ->
return Version.parse(jvm)
}
}

// unknown version
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ public data class VMStaticProperty internal constructor (
)

private fun currentVersion(): SemanticVersion? {
// example: 20.0.2+9-jvmci-23.0-b14
return System.getProperty("java.vm.version").let { vmVersion ->
// example: 20.0.2+9-jvmci-23.0-b14 (or) 21.0.2+13-LTS-jvmci-23.1-b30
return (System.getProperty("java.vm.version") ?: "unknown").lowercase().trim().let { vmVersion ->
when {
// running on JVM
vmVersion.contains("jvmci") -> parseSemanticVersion(vmVersion.split("-")[2])
vmVersion.contains("jvmci") -> if (vmVersion.contains("lts")) {
parseSemanticVersion(vmVersion.split("-")[3])
} else {
parseSemanticVersion(vmVersion.split("-")[2])
}

// in a native image, we'll need to translate the SVM release to a known SDK release
ImageInfo.inImageCode() -> parseSemanticVersion(
Expand Down

0 comments on commit b5691f3

Please sign in to comment.