Skip to content

Commit b7f9ac4

Browse files
committed
java_version,api: simplify use
1 parent b11fe3b commit b7f9ac4

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

+stdlib/inode.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
if stdlib.has_python()
1313
i = uint64(py.pathlib.Path(path).stat().st_ino);
14-
elseif isunix() && stdlib.has_java() && stdlib.java_api() >= 11
14+
elseif isunix() && stdlib.java_api() >= 11
1515
% Java 1.8 is buggy in some corner cases, so we require at least 11.
1616
opt = javaMethod("values", "java.nio.file.LinkOption");
1717
i = javaMethod("getAttribute", "java.nio.file.Files", javaPathObject(path), "unix:ino", opt);

+stdlib/java_version.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
function v = java_version()
1111

12-
v = javaMethod("getProperty", "java.lang.System", "java.version");
12+
try
13+
v = javaMethod("getProperty", "java.lang.System", "java.version");
14+
catch
15+
v = '';
16+
end
1317

1418
try %#ok<*TRYNC>
1519
v = string(v);

+stdlib/samepath.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
f1 = System.IO.Path.GetFullPath(path1).TrimEnd(separators);
3333
f2 = System.IO.Path.GetFullPath(path2).TrimEnd(separators);
3434
y = System.String.Equals(f1, f2, System.StringComparison.OrdinalIgnoreCase);
35-
elseif stdlib.has_java() && stdlib.java_api() >= 11
35+
elseif stdlib.java_api() >= 11
3636
% https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/nio/file/Files.html#isSameFile(java.nio.file.Path,java.nio.file.Path)
3737
% Java 1.8 is buggy in some corner cases, so we require at least 11.
3838
y = java.nio.file.Files.isSameFile(javaPathObject(path1), javaPathObject(path2));

test/TestDisk.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function test_filesystem_type(tc, Ps)
6060

6161
function test_device(tc)
6262

63-
tc.assumeTrue(stdlib.has_python() || (isunix() && stdlib.has_java() && stdlib.java_api() >= 11))
63+
tc.assumeTrue(stdlib.has_python() || (isunix() && stdlib.java_api() >= 11))
6464

6565
if ispc()
6666
tc.verifyGreaterThan(stdlib.device(pwd()), 0)
@@ -71,7 +71,7 @@ function test_device(tc)
7171

7272

7373
function test_inode(tc)
74-
tc.assumeTrue(stdlib.has_python() || (~ispc() && stdlib.has_java() && stdlib.java_api() >= 11))
74+
tc.assumeTrue(stdlib.has_python() || (~ispc() && stdlib.java_api() >= 11))
7575

7676
tc.verifyEqual(stdlib.inode("."), stdlib.inode(pwd()))
7777
end

0 commit comments

Comments
 (0)