Skip to content

Commit 3b30d08

Browse files
committed
Fix remaining OpenJDK-25-related issues
* Relax version digit length checks. * Handle wonky JVM paths on macOS. * Fix typo.
1 parent 6eebe95 commit 3b30d08

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/scyjava/_cjdk_fetch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _silent_check_output(*args, **kwargs):
4747
try:
4848
with patch.object(subprocess, "check_output", new=_silent_check_output):
4949
jpype.getDefaultJVMPath()
50-
# on Darwin, may raise a CalledProcessError when invoking `/user/libexec/java_home`
50+
# on Darwin, may raise a CalledProcessError when invoking `/usr/libexec/java_home`
5151
except (jpype.JVMNotFoundException, subprocess.CalledProcessError):
5252
return False
5353
return True

src/scyjava/_jvm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@ def jvm_version() -> tuple[int, ...]:
7070
default_jvm_path = jpype.getDefaultJVMPath()
7171
if not default_jvm_path:
7272
raise RuntimeError("Cannot glean the default JVM path")
73+
print(f"Default JVM path from JPype: {default_jvm_path}")
7374

74-
p = Path(default_jvm_path)
75+
# Good ol' macOS! Nothing beats macOS.
76+
jvm_path = default_jvm_path.replace(
77+
"/Contents/MacOS/libjli.dylib", "/Contents/Home/lib/libjli.dylib"
78+
)
79+
80+
p = Path(jvm_path)
7581
if not p.exists():
7682
raise RuntimeError(f"Invalid default JVM path: {p}")
7783

tests/it/jvm_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
before_version = scyjava.jvm_version()
1212
assert_that(before_version).is_not_none()
13-
assert_that(len(before_version)).is_greater_than_or_equal_to(3)
13+
assert_that(len(before_version)).is_greater_than_or_equal_to(1)
1414
assert_that(before_version[0]).is_greater_than(0)
1515

1616
scyjava.config.enable_headless_mode()
1717
scyjava.start_jvm()
1818

1919
after_version = scyjava.jvm_version()
2020
assert_that(after_version).is_not_none()
21-
assert_that(len(after_version)).is_greater_than_or_equal_to(3)
21+
assert_that(len(after_version)).is_greater_than_or_equal_to(1)
2222
assert_that(after_version[0]).is_greater_than(0)
2323

2424
assert_that(before_version).is_equal_to(after_version)

0 commit comments

Comments
 (0)