Skip to content

Commit 96fb532

Browse files
committed
samepath: java >= 11
1 parent ffd6ed6 commit 96fb532

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

+stdlib/device.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
path {mustBeTextScalar}
88
end
99

10+
i = [];
11+
1012
if stdlib.exists(path)
1113
if stdlib.isoctave()
1214
[s, err] = stat(path);
1315
if err == 0
1416
i = s.dev;
1517
end
16-
else
18+
elseif stdlib.has_java() && stdlib.java_api() >= 11
19+
% Java 1.8 is buggy in some corner cases, so we require at least 11.
1720
i = java.nio.file.Files.getAttribute(javaPathObject(path), "unix:dev", javaLinkOption());
1821
end
19-
else
20-
i = [];
2122
end
2223

2324
end

+stdlib/inode.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
if err == 0
1616
i = s.ino;
1717
end
18-
else
18+
elseif stdlib.has_java() && stdlib.java_api() >= 11
19+
% Java 1.8 is buggy in some corner cases, so we require at least 11.
1920
i = java.nio.file.Files.getAttribute(javaPathObject(path), "unix:ino", javaLinkOption());
2021
end
21-
else
22-
i = [];
2322
end
2423

2524
end

+stdlib/java_api.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
a = strsplit(v, '.');
1111
if(isempty(a))
12-
api = 0;
12+
api = [];
1313
return
1414
end
1515

@@ -22,4 +22,4 @@
2222
end
2323

2424

25-
%!assert(java_api() > 0)
25+
%!assert(!isempty(java_api()))

+stdlib/samepath.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
y = e1 == 0 && e2 == 0 && ...
2929
r1.ino == r2.ino && r1.dev == r2.dev;
3030

31-
elseif stdlib.has_java()
31+
elseif stdlib.has_java() && stdlib.java_api() >= 11
3232
% 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)
33-
33+
% Java 1.8 is buggy in some corner cases, so we require at least 11.
3434
y = java.nio.file.Files.isSameFile(javaPathObject(path1), javaPathObject(path2));
3535

3636
else

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ jobs:
5656
- name: Check CodeIssues
5757
uses: ./.github/workflows/composite-check
5858

59+
# https://www.mathworks.com/support/requirements/openjdk.html
60+
# old matlab may segfault with too-new JDK
5961
- name: matlab_jenv JDK 11
60-
if: ${{ matrix.release < 'R2025a' && !startsWith(matrix.release, 'latest') }}
62+
if: ${{ matrix.release >= 'R2023a' && matrix.release < 'R2025a' && !startsWith(matrix.release, 'latest') }}
6163
run: matlab_jenv ${JAVA_HOME_11_X64}
6264

6365
- name: Matlab tell Java Version

Readme_java.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ Get the Java version:
3636
stdlib.java_version()
3737
```
3838

39-
From before Matlab R2019b to at least Matlab R2025a, the Matlab factory Java version is 1.8, which is adequate for all Matlab-stdlib functionality.
39+
From before Matlab R2019b to at least Matlab R2025a, the Matlab factory Java version is 1.8, which is adequate for most Matlab-stdlib functionality.
40+
Java 11 or newer is recommended for more robustness if relying on Java functionality.
4041

4142
If desired (not used by Matlab-stdlib), one can use non-factory Java classes in
4243
[Matlab](](https://www.mathworks.com/help/matlab/matlab_external/static-path-of-java-class-path.html))

test/TestJava.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function java_required(tc)
1515

1616
function test_inode(tc)
1717
tc.assumeFalse(ispc(), "not for Windows")
18+
tc.assumeGreaterThanOrEqual(stdlib.java_api(), 11)
1819

1920
tc.verifyEqual(stdlib.inode("."), stdlib.inode(pwd()))
2021
tc.verifyEmpty(stdlib.inode(tempname))
@@ -23,6 +24,7 @@ function test_inode(tc)
2324

2425
function test_device(tc)
2526
tc.assumeFalse(ispc(), "not for Windows")
27+
tc.assumeGreaterThanOrEqual(stdlib.java_api(), 11)
2628

2729
tc.verifyEqual(stdlib.device("."), stdlib.device(pwd()))
2830
tc.verifyEmpty(stdlib.device(tempname))

0 commit comments

Comments
 (0)