Skip to content

Commit

Permalink
Java HotSpot support, test and better doc
Browse files Browse the repository at this point in the history
  • Loading branch information
roi-granulate committed Aug 16, 2023
1 parent 882a935 commit 1280c9c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions granulate_utils/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,18 @@ def parse_jvm_version(version_string: str) -> JvmVersion:
build = int(matched[0])

# There is no real format here, just use the entire description string until the part which describes the build.
m = re.match(r"(.*?) \((?:product )?build", lines[2])
m = re.match(r"(.*?) (?:\(.*\))?\((?:product )?build", lines[2])
assert m is not None, f"Missing build description? {lines[2]}"
vm_name = m.group(1)

if vm_name.startswith("OpenJDK"):
if vm_name.startswith("OpenJDK") or vm_name.startswith("Java HotSpot"):
vm_type: VmType = "HotSpot"
elif vm_name.startswith("Zing"):
vm_type = "Zing"
elif vm_name == "Eclipse OpenJ9 VM":
vm_type = "OpenJ9"
else:
# TODO: additional types?
# There may be additional types that have not yet been categorized.
vm_type = None

if vm_type == "Zing":
Expand Down
14 changes: 14 additions & 0 deletions tests/granulate_utils/test_jvm_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
@pytest.mark.parametrize(
"java_version,jvm_version_or_err",
[
(
"""java version "18.0.0.1" 2022-05-19
Java(TM) SE Runtime Environment (build 18.0.0.1+2-9)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.0.1+2-9, mixed mode, sharing)
""",
JvmVersion(Version("18.0.0.1"), 2, "Java HotSpot(TM) 64-Bit Server VM", "HotSpot", None),
),
(
"""openjdk version "1.8.0_125"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_125-b09)
OpenJDK 64-Bit Server VM (Temurin)(build 25.125-b09, mixed mode)
""",
JvmVersion(Version("8.125"), 9, "OpenJDK 64-Bit Server VM", "HotSpot", None),
),
# 8
(
"""openjdk version "1.8.0_352"
Expand Down

0 comments on commit 1280c9c

Please sign in to comment.