Mercurial > octave
annotate scripts/java/javaaddpath.m @ 33634:4a70f390c85e default tip @
maint: Merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 28 May 2024 15:25:54 +0200 |
parents | 2e484f9f1f18 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
3 ## Copyright (C) 2007-2024 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27876
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 ## |
15746
da26f72408a7
update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
8 ## This file is part of Octave. |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
15746
da26f72408a7
update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
15746
da26f72408a7
update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
14 ## |
da26f72408a7
update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
da26f72408a7
update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 ## |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
15746
da26f72408a7
update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20160
diff
changeset
|
27 ## @deftypefn {} {} javaaddpath (@var{clspath}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20160
diff
changeset
|
28 ## @deftypefnx {} {} javaaddpath (@var{clspath1}, @dots{}) |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
29 ## @deftypefnx {} {} javaaddpath (@{@var{clspath1}, @dots{}@}) |
27875
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
30 ## @deftypefnx {} {} javaaddpath (@dots{}, "-end") |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
31 ## Add @var{clspath} to the beginning of the dynamic class path of the |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
32 ## Java virtual machine. |
20160
03b9d17a2d95
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19593
diff
changeset
|
33 ## |
03b9d17a2d95
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19593
diff
changeset
|
34 ## @var{clspath} may either be a directory where @file{.class} files are |
03b9d17a2d95
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19593
diff
changeset
|
35 ## found, or a @file{.jar} file containing Java classes. Multiple paths may |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
36 ## be added at once by specifying additional arguments, or by using a cell |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
37 ## array of strings. |
27875
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
38 ## |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
39 ## If the final argument is @qcode{"-end"}, append the new element to the |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
40 ## end of the current classpath. |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
41 ## |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15748
diff
changeset
|
42 ## @seealso{javarmpath, javaclasspath} |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 ## @end deftypefn |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15748
diff
changeset
|
45 function javaaddpath (varargin) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15748
diff
changeset
|
47 if (nargin < 1) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 print_usage (); |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15748
diff
changeset
|
49 endif |
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15748
diff
changeset
|
50 |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
51 if (! all (cellfun (@(c) ischar (c) || iscellstr (c), varargin))) |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
52 error ("javaaddpath: arguments must be strings or cell array of strings"); |
27875
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
53 endif |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
54 |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
55 if (strcmp (varargin{end}, "-end")) |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
56 at_end = true; |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
57 varargin(end) = []; |
27875
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
58 else |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
59 ## Note that when prepending, we iterate over the arguments in |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
60 ## reverse so that a call like |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
61 ## |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
62 ## javaaddpath ("/foo", "/bar") |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
63 ## |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
64 ## results in "/foo" first in the path followed by "/bar". |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
65 at_end = false; |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
66 varargin = fliplr (varargin); |
27875
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
67 endif |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
68 |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
69 for arg = varargin |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
70 if (iscellstr (arg{1})) |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
71 if (at_end) |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
72 ## Guarantee cellstr array is a row vector |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
73 arg = arg{1}(:).'; |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
74 else |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
75 ## Iterate in reverse over cell arrays |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
76 arg = fliplr (arg{1}(:).'); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 endif |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 endif |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15748
diff
changeset
|
79 |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
80 for clspath = arg |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
81 clspath = clspath{1}; |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
82 |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
83 new_path = canonicalize_file_name (tilde_expand (clspath)); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
84 if (isfolder (new_path)) |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
85 if (new_path(end) != filesep ()) |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
86 new_path = [new_path, filesep()]; |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
87 endif |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
88 elseif (! exist (new_path, "file")) |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
89 error ("javaaddpath: CLSPATH does not exist: %s", clspath); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
90 endif |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
91 |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
92 success = javaMethod ("addClassPath", "org.octave.ClassHelper", |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
93 new_path, at_end); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
94 |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
95 if (! success) |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
96 warning ("javaaddpath: failed to add '%s' to Java classpath", new_path); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
97 endif |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
98 endfor |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
99 endfor |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
100 |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 endfunction |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
102 |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
103 |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
104 ## FIXME: These tests may fail if either TEMPDIR or HOME have already |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
105 ## been added to the Java class path. |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
106 |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
107 ## Basic prepend test with single string |
28168
b3bd3385d07a
* javaaddpath.m, javarmpath.m: Skip BISTs if Java is unavailable on run-time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28033
diff
changeset
|
108 %!testif HAVE_JAVA; usejava ("jvm") |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
109 %! pth = tempdir (); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
110 %! unwind_protect |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
111 %! clspth1 = javaclasspath ("-dynamic"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
112 %! javaaddpath (pth); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
113 %! clspth2 = javaclasspath ("-dynamic"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
114 %! assert (clspth2{1}, canonicalize_file_name (pth)); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
115 %! assert (clspth2(2:end), clspth1(1:end)); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
116 %! unwind_protect_cleanup |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
117 %! javarmpath (pth); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
118 %! end_unwind_protect |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
119 |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
120 ## Prepend test with two strings |
28168
b3bd3385d07a
* javaaddpath.m, javarmpath.m: Skip BISTs if Java is unavailable on run-time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28033
diff
changeset
|
121 %!testif HAVE_JAVA; usejava ("jvm") |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
122 %! pth1 = tempdir (); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
123 %! pth2 = tilde_expand ("~"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
124 %! unwind_protect |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
125 %! clspth1 = javaclasspath ("-dynamic"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
126 %! javaaddpath (pth1, pth2); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
127 %! clspth2 = javaclasspath ("-dynamic"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
128 %! assert (clspth2([1, 2]), |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
129 %! {canonicalize_file_name(pth1), canonicalize_file_name(pth2)}); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
130 %! assert (clspth2(3:end), clspth1(1:end)); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
131 %! unwind_protect_cleanup |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
132 %! javarmpath (pth1, pth2); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
133 %! end_unwind_protect |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
134 |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
135 ## Prepend test with cell array of two strings |
28168
b3bd3385d07a
* javaaddpath.m, javarmpath.m: Skip BISTs if Java is unavailable on run-time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28033
diff
changeset
|
136 %!testif HAVE_JAVA; usejava ("jvm") |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
137 %! pth1 = tempdir (); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
138 %! pth2 = tilde_expand ("~"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
139 %! unwind_protect |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
140 %! clspth1 = javaclasspath ("-dynamic"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
141 %! javaaddpath ({pth1, pth2}); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
142 %! clspth2 = javaclasspath ("-dynamic"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
143 %! assert (clspth2([1, 2]), |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
144 %! {canonicalize_file_name(pth1), canonicalize_file_name(pth2)}); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
145 %! assert (clspth2(3:end), clspth1(1:end)); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
146 %! unwind_protect_cleanup |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
147 %! javarmpath (pth1, pth2); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
148 %! end_unwind_protect |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
149 |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
150 ## Append test with two strings |
28168
b3bd3385d07a
* javaaddpath.m, javarmpath.m: Skip BISTs if Java is unavailable on run-time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28033
diff
changeset
|
151 %!testif HAVE_JAVA; usejava ("jvm") |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
152 %! pth1 = tempdir (); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
153 %! pth2 = tilde_expand ("~"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
154 %! unwind_protect |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
155 %! clspth1 = javaclasspath ("-dynamic"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
156 %! javaaddpath (pth1, pth2, "-end"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
157 %! clspth2 = javaclasspath ("-dynamic"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
158 %! assert (clspth2([end-1, end]), |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
159 %! {canonicalize_file_name(pth1), canonicalize_file_name(pth2)}); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
160 %! assert (clspth2(1:end-2), clspth1(1:end)); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
161 %! unwind_protect_cleanup |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
162 %! javarmpath (pth1, pth2); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
163 %! end_unwind_protect |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
164 |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
165 ## Append test with cell array of two strings |
28168
b3bd3385d07a
* javaaddpath.m, javarmpath.m: Skip BISTs if Java is unavailable on run-time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28033
diff
changeset
|
166 %!testif HAVE_JAVA; usejava ("jvm") |
27876
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
167 %! pth1 = tempdir (); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
168 %! pth2 = tilde_expand ("~"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
169 %! unwind_protect |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
170 %! clspth1 = javaclasspath ("-dynamic"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
171 %! javaaddpath ({pth1, pth2}, "-end"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
172 %! clspth2 = javaclasspath ("-dynamic"); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
173 %! assert (clspth2([end-1, end]), |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
174 %! {canonicalize_file_name(pth1), canonicalize_file_name(pth2)}); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
175 %! assert (clspth2(1:end-2), clspth1(1:end)); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
176 %! unwind_protect_cleanup |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
177 %! javarmpath (pth1, pth2); |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
178 %! end_unwind_protect |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
179 |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
180 ## Test input validation |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
181 %!error <Invalid call> javaaddpath () |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
182 %!error <arguments must be strings> javaaddpath (5) |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
183 %!error <arguments must be .* cell array of strings> javaaddpath ({5}) |
76373f5113db
javaddpath.m: Allow cellstr inputs (bug #57487)
Rik <rik@octave.org>
parents:
27875
diff
changeset
|
184 %!error <CLSPATH does not exist> javaaddpath ("%_A_Very_Unlikely_Name_%") |