Mercurial > octave
annotate scripts/java/javachk.m @ 27957:c20b7290c778
merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 17 Jan 2020 13:27:27 -0600 |
parents | bd51beb6205e 2310164737b3 |
children | bdad8ca48700 |
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 ## |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 ## Copyright (C) 2014-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27484
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/>. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
7 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23405
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
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:
23405
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:
22497
diff
changeset
|
13 ## (at your option) any later version. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
14 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22497
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22497
diff
changeset
|
18 ## GNU General Public License for more details. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
19 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
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:
23405
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 ######################################################################## |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
25 |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
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 {} {} javachk (@var{feature}) |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
28 ## @deftypefnx {} {} javachk (@var{feature}, @var{caller}) |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20160
diff
changeset
|
29 ## @deftypefnx {} {@var{msg} =} javachk (@dots{}) |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
30 ## Check for the presence of the Java @var{feature} in the current session. |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
31 ## Return an error structure if @var{feature} is not available, not enabled, |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
32 ## or not recognized. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
33 ## |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
34 ## Possible recognized features are: |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
35 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
36 ## @table @asis |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
37 ## @item @nospell{@qcode{"awt"}} |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
38 ## Abstract Window Toolkit for GUIs. |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
39 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
40 ## @item @qcode{"desktop"} |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
41 ## Interactive desktop is running. |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
42 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
43 ## @item @qcode{"jvm"} |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
44 ## Java Virtual Machine. |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
45 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
46 ## @item @qcode{"swing"} |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
47 ## Swing components for lightweight GUIs. |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
48 ## @end table |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
49 ## |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
50 ## If @var{feature} is not supported, a scalar struct with field |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
51 ## @qcode{"message"} and @qcode{"identifier"} is returned. The field |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
52 ## @qcode{"message"} contains an error message mentioning @var{feature} as |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
53 ## well as the optional user-specified @var{caller}. This structure is |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
54 ## suitable for passing in to the @code{error} function. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
55 ## |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
56 ## If @var{feature} is supported and available, an empty struct array is |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
57 ## returned with fields @qcode{"message"} and @qcode{"identifier"}. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
58 ## |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
59 ## @code{javachk} determines if specific Java features are available in an |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
60 ## Octave session. This function is provided for scripts which may alter |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
61 ## their behavior based on the availability of Java or specific Java runtime |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
62 ## features. |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
63 ## |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
64 ## Compatibility Note: The feature @qcode{"desktop"} is never available since |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
65 ## Octave has no Java-based desktop. |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
66 ## |
20160
03b9d17a2d95
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
67 ## @seealso{usejava, error} |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
68 ## @end deftypefn |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
69 |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
70 ## Author: Philip Nienhuis <prnienhuis at users.sf.net> |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
71 ## Created: 2014-04-19 |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
72 |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
73 function msg = javachk (feature, caller = "") |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
74 |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
75 if (nargin < 1 || nargin > 2) |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
76 print_usage (); |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
77 elseif (! ischar (feature)) |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
78 error ("javachk: FEATURE must be a string"); |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
79 elseif (! ischar (caller)) |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
80 error ("javachk: CALLER must be a string"); |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
81 endif |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
82 |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
83 if (isempty (caller)) |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
84 caller = "this function"; |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
85 endif |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
86 |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
87 msg = struct ("message", "", "identifier", ""); |
27436
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
88 |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
89 ## Check that Octave was compiled with Java support |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
90 chk = logical (__octave_config_info__ ("build_features").JAVA); |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
91 if (! chk) |
27436
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
92 msg.message = sprintf (["javachk: %s is not supported, " ... |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
93 "Octave was not compiled with Java support"], |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
94 caller); |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
95 msg.identifier = "Octave:javachk:java-not-supported"; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
96 endif |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
97 |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
98 if (chk) |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
99 chk = false; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
100 ## For each feature, try methods() on a Java class of a feature |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
101 switch (feature) |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
102 case "awt" |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
103 try |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
104 dum = methods ("java.awt.Frame"); |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
105 chk = true; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
106 end_try_catch |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
107 case "desktop" |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
108 ## Octave has no Java based GUI/desktop, leave chk = false |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
109 case "jvm" |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
110 try |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
111 dum = methods ("java.lang.Runtime"); |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
112 chk = true; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
113 end_try_catch |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
114 case "swing" |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
115 try |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
116 dum = methods ("javax.swing.Popup"); |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
117 chk = true; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
118 end_try_catch |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
119 otherwise |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
120 ## Unrecognized feature is the same as disabled feature |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
121 endswitch |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
122 |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
123 if (! chk) |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
124 msg.message = sprintf (['javachk: %s is not supported, Java feature '... |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
125 '"%s" is not available'], caller, feature); |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
126 msg.identifier = "Octave:javachk:feature-not-available"; |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
127 endif |
ece17410605e
javachk.m: Add additional check for whether Octave was compiled with Java support (bug #55429).
Rik <rik@octave.org>
parents:
26607
diff
changeset
|
128 |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
129 endif |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
130 |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
131 if (isempty (msg.message)) |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26607
diff
changeset
|
132 ## Compatibility: Matlab returns a 0x1 empty struct when javachk passes |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
133 msg = resize (msg, 0, 1); |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
134 endif |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
135 |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
136 endfunction |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
137 |
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
138 |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
139 %!testif ; ! __octave_config_info__().build_features.JAVA |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
140 %! msg = javachk ("desktop"); |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
141 %! assert (msg.message, "javachk: this function is not supported, Octave was not compiled with Java support"); |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
142 %! assert (msg.identifier, "Octave:javachk:java-not-supported"); |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
143 |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
144 %!testif HAVE_JAVA |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
145 %! msg = javachk ("desktop"); |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
146 %! assert (msg.message, 'javachk: this function is not supported, Java feature "desktop" is not available'); |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
147 %! assert (msg.identifier, "Octave:javachk:feature-not-available"); |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
148 |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
149 %!testif HAVE_JAVA |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
150 %! msg = javachk ("desktop", "Java DESKTOP"); |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
151 %! assert (msg.message, 'javachk: Java DESKTOP is not supported, Java feature "desktop" is not available'); |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
152 %! assert (msg.identifier, "Octave:javachk:feature-not-available"); |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
153 |
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
154 %!testif HAVE_JAVA |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
155 %! msg = javachk ("nosuchfeature"); |
27484
1dbe2d38673f
javachk.m: Update BIST tests for new behavior (bug #55429).
Rik <rik@octave.org>
parents:
27436
diff
changeset
|
156 %! assert (msg.message, 'javachk: this function is not supported, Java feature "nosuchfeature" is not available'); |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
157 %! assert (msg.identifier, "Octave:javachk:feature-not-available"); |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
158 |
23405
32ec90068be5
use %!testif runtime tests to properly skip java tests
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
159 %!testif HAVE_JAVA; usejava ("jvm") |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
160 %! stnul = resize (struct ("message", "", "identifier", ""), 0, 1); |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
161 %! assert (javachk ("jvm"), stnul); |
18721
700714c099a2
Add new function javachk for Matlab compatibility.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
diff
changeset
|
162 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
163 ## Test input validation |
26607
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
164 %!error javachk () |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
165 %!error javachk (1) |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
166 %!error javachk ("jvm", 2) |
a7502ba98540
javachk.m: overhaul function and doc string for compatibility with Matlab
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
167 %!error javachk ("jvm", "feature", "ok") |