Mercurial > hg > octave-lyh
changeset 15752:f96faf028d90
make java functions part of core octave_value classes
* run-octave.in: Set OCTAVE_JAVA_DIR.
* octave-value/ov-java.cc: Rename from dldfcn/__java__.cc.
(get_module_path): Delete.
(initial_java_dir): Don't set architecture dependent directory.
Check environment or use Vfcn_file_dir to set default directory.
(initial_class_path): Don't search load path for octave.jar.
(initialize_jvm): Don't add -Doctave.java.path=DIR to vm_args.
Use DEFUN, not DEFUN_DLD.
(F__java__): Delete.
* octave-value/ov-java.h: Rename from dldfcn/__java__.h.
* dldfcn/module-files: Delete entry for __java__.cc.
* libinterp/Makefile.am (octinclude_HEADERS): Delete $(DLDFCN_INC)
from the list.
* octave-value/module.mk (OCTAVE_VALUE_INC): Add ov-java.h to the list.
(OCTAVE_VALUE_SRC) Add ov-java.cc to the list.
(octave_value_liboctave_value_la_LIBADD): New variable.
(octave_value_liboctave_value_la_CPPFLAGS): Add $(JAVA_CPPFLAGS) to
the list.
* dldfcn/config-module.awk: Don't print DLDFCN_INC variable.
* Octave.java, OctaveReference.java: Don't grab a reference to
__java__.oct.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 08 Dec 2012 00:23:13 -0500 |
parents | 72968fb32c82 |
children | 6e39fe7992d9 |
files | libinterp/Makefile.am libinterp/dldfcn/__java__.cc libinterp/dldfcn/__java__.h libinterp/dldfcn/config-module.awk libinterp/dldfcn/module-files libinterp/octave-value/module.mk libinterp/octave-value/ov-java.cc libinterp/octave-value/ov-java.h run-octave.in scripts/java/org/octave/Octave.java scripts/java/org/octave/OctaveReference.java |
diffstat | 9 files changed, 52 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/Makefile.am +++ b/libinterp/Makefile.am @@ -107,8 +107,7 @@ $(PARSE_TREE_INC) \ $(OPERATORS_INC) \ $(INTERP_CORE_INC) \ - $(INTERPFCN_INC) \ - $(DLDFCN_INC) + $(INTERPFCN_INC) nodist_octinclude_HEADERS = \ interp-core/mxarray.h \
--- a/libinterp/dldfcn/config-module.awk +++ b/libinterp/dldfcn/config-module.awk @@ -10,10 +10,6 @@ print " dldfcn/module-files \\" print " dldfcn/oct-qhull.h" print "" -## Kluge... - print "DLDFCN_INC = \\" - print " dldfcn/__java__.h" - print "" } /^#.*/ { next; } {
--- a/libinterp/dldfcn/module-files +++ b/libinterp/dldfcn/module-files @@ -5,7 +5,6 @@ __glpk__.cc|$(GLPK_CPPFLAGS)|$(GLPK_LDFLAGS)|$(GLPK_LIBS) __init_fltk__.cc|$(GRAPHICS_CFLAGS) $(FT2_CPPFLAGS)|$(GRAPHICS_LDFLAGS) $(FT2_LDFLAGS)|$(GRAPHICS_LIBS) $(FT2_LIBS) __init_gnuplot__.cc -__java__.cc|$(JAVA_CPPFLAGS)||$(JAVA_LIBS) __magick_read__.cc|$(MAGICK_CPPFLAGS)|$(MAGICK_LDFLAGS)|$(MAGICK_LIBS) __voronoi__.cc|$(QHULL_CPPFLAGS)|$(QHULL_LDFLAGS)|$(QHULL_LIBS) amd.cc|$(SPARSE_XCPPFLAGS)|$(SPARSE_XLDFLAGS)|$(SPARSE_XLIBS)
--- a/libinterp/octave-value/module.mk +++ b/libinterp/octave-value/module.mk @@ -51,6 +51,7 @@ octave-value/ov-flt-cx-mat.h \ octave-value/ov-flt-re-diag.h \ octave-value/ov-flt-re-mat.h \ + octave-value/ov-java.h \ octave-value/ov-lazy-idx.h \ octave-value/ov-mex-fcn.h \ octave-value/ov-null-mat.h \ @@ -108,6 +109,7 @@ octave-value/ov-flt-cx-mat.cc \ octave-value/ov-flt-re-diag.cc \ octave-value/ov-flt-re-mat.cc \ + octave-value/ov-java.cc \ octave-value/ov-lazy-idx.cc \ octave-value/ov-mex-fcn.cc \ octave-value/ov-null-mat.cc \ @@ -128,4 +130,14 @@ noinst_LTLIBRARIES += octave-value/liboctave-value.la octave_value_liboctave_value_la_SOURCES = $(OCTAVE_VALUE_SRC) -octave_value_liboctave_value_la_CPPFLAGS = $(liboctinterp_la_CPPFLAGS) + +## FIXME -- maybe it would be better to limit the JAVA flags to +## the compile commands for ov-java.cc? Does JAVA_LIBS need to be +## added to LIBOCTINTERP_LINK_DEPS (see libinterp/link-deps.mk)? +## Should we have a separate set of JAVA_LDFLAGS? + +octave_value_liboctave_value_la_CPPFLAGS = \ + $(liboctinterp_la_CPPFLAGS) \ + $(JAVA_CPPFLAGS) + +octave_value_liboctave_value_la_LIBADD = $(JAVA_LIBS)
rename from libinterp/dldfcn/__java__.cc rename to libinterp/octave-value/ov-java.cc --- a/libinterp/dldfcn/__java__.cc +++ b/libinterp/octave-value/ov-java.cc @@ -38,14 +38,15 @@ #include <clocale> #include "Cell.h" -#include "__java__.h" #include "cmd-edit.h" -#include "defun-dld.h" +#include "defaults.h" +#include "defun.h" #include "file-ops.h" #include "file-stat.h" #include "load-path.h" #include "oct-env.h" #include "oct-shlib.h" +#include "ov-java.h" #include "parse.h" #include "variables.h" @@ -252,51 +253,19 @@ #endif static std::string -get_module_path (const std::string& name, bool strip_name = true) +initial_java_dir (void) { - std::string retval; - - retval = octave_env::make_absolute (load_path::find_file (name), - octave_env::get_current_directory ()); - - if (! retval.empty ()) - { - if (strip_name) - { - size_t pos = retval.rfind (file_ops::dir_sep_str () + name); - - if (pos != std::string::npos) - retval.resize (pos); - else - throw std::string ("No module path in ") + retval; - } - } - else - throw std::string ("Could not find file ") + name; + static std::string java_dir; - return retval; -} - -static std::string -initial_java_dir (bool arch_dependent = false) -{ - static std::string path1; - static std::string path2; - - if (arch_dependent) + if (java_dir.empty ()) { - if (path1.empty ()) - path1 = get_module_path ("__java__.oct", true); + java_dir = octave_env::getenv ("OCTAVE_JAVA_DIR"); - return path1; + if (java_dir.empty ()) + java_dir = Vfcn_file_dir + file_ops::dir_sep_str () + "java"; } - else - { - if (path2.empty ()) - path2 = get_module_path ("javaclasspath.m", true); - return path2; - } + return java_dir; } // Read the content of a file filename (usually "classpath.txt") @@ -350,12 +319,17 @@ static std::string initial_class_path (void) { - std::string retval = initial_java_dir (); + std::string java_dir = initial_java_dir (); + + std::string retval = java_dir; // find octave.jar file if (! retval.empty ()) { - std::string jar_file = get_module_path ("octave.jar", false); + std::string sep = file_ops::dir_sep_str (); + + std::string jar_file = java_dir + sep + "octave.jar"; + file_stat jar_exists (jar_file); if (jar_exists) @@ -363,7 +337,6 @@ // initialize static classpath to octave.jar retval = jar_file; - // The base classpath has been set. Try to find the optional // file "classpath.txt" in two places. The users classes will // take precedence over the settings defined in the package @@ -376,7 +349,8 @@ // Try to read the file "classpath.txt" in the user's home // directory. - cp_file = file_ops::tilde_expand ("~" + file_ops::dir_sep_str () + str_filename); + std::string home_dir = "~" + sep + str_filename; + cp_file = file_ops::tilde_expand (home_dir); cp_exists = file_stat (cp_file); if (cp_exists) { @@ -389,7 +363,7 @@ // Try to read a file "classpath.txt" in the package directory. - cp_file = initial_java_dir () + file_ops::dir_sep_str () + str_filename; + cp_file = java_dir + sep + str_filename; cp_exists = file_stat (cp_file); if (cp_exists) { @@ -554,10 +528,9 @@ JVMArgs vm_args; vm_args.add ("-Djava.class.path=" + initial_class_path ()); - vm_args.add ("-Doctave.java.path=" + initial_java_dir (true)); vm_args.add ("-Xrs"); vm_args.add ("-Djava.system.class.loader=org.octave.OctClassLoader"); - vm_args.read_java_opts (initial_java_dir (false) + file_ops::dir_sep_str () + "java.opts"); + vm_args.read_java_opts (initial_java_dir () + file_ops::dir_sep_str () + "java.opts"); # if !defined (__APPLE__) && !defined (__MACH__) @@ -571,7 +544,7 @@ #else if (JNI_CreateJavaVM (&jvm, reinterpret_cast<void **> (¤t_env), - vm_args.to_args ()) != JNI_OK) + vm_args.to_args ()) != JNI_OK) throw std::string ("unable to start Java VM in ")+jvm_lib_path; } @@ -1390,7 +1363,7 @@ } } -DEFUN_DLD (java_init, , , +DEFUN (java_init, , , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} java_init ()\n\ Undocumented internal function.\n\ @@ -1406,7 +1379,7 @@ return retval; } -DEFUN_DLD (java_exit, , , +DEFUN (java_exit, , , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} java_exit ()\n\ Undocumented internal function.\n\ @@ -1419,7 +1392,7 @@ return retval; } -DEFUN_DLD (java_new, args, , +DEFUN (java_new, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{obj} =} java_new (@var{name}, @var{arg1}, ...)\n\ Create a Java object of class @var{name}, by calling the class constructor with the\n\ @@ -1435,7 +1408,7 @@ return _java_new (args); } -DEFUN_DLD (javaObject, args, , +DEFUN (javaObject, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{obj} =} javaObject (@var{name}, @var{arg1}, ...)\n\ Create a Java object of class @var{name}, by calling the class constructor with the\n\ @@ -1484,7 +1457,7 @@ return retval; } -DEFUN_DLD (java_invoke, args, , +DEFUN (java_invoke, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{ret} =} java_invoke (@var{obj}, @var{name}, @var{arg1}, ...)\n\ Invoke the method @var{name} on the Java object @var{obj} with the arguments\n\ @@ -1506,7 +1479,7 @@ return _java_invoke (args); } -DEFUN_DLD (javaMethod, args, , +DEFUN (javaMethod, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{ret} =} javaMethod (@var{name}, @var{obj}, @var{arg1}, ...)\n\ Invoke the method @var{name} on the Java object @var{obj} with the arguments\n\ @@ -1594,7 +1567,7 @@ return retval; } -DEFUN_DLD (java_get, args, , +DEFUN (java_get, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{val} =} java_get (@var{obj}, @var{name})\n\ Get the value of the field @var{name} of the Java object @var{obj}. For\n\ @@ -1648,7 +1621,7 @@ return retval; } -DEFUN_DLD (java_set, args, , +DEFUN (java_set, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{obj} =} java_set (@var{obj}, @var{name}, @var{val})\n\ Set the value of the field @var{name} of the Java object @var{obj} to @var{val}.\n\ @@ -1702,7 +1675,7 @@ return retval; } -DEFUN_DLD (java2mat, args, , +DEFUN (java2mat, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} java2mat (@var{obj})\n\ Undocumented internal function.\n\ @@ -1733,16 +1706,7 @@ return retval; } -DEFUN_DLD (__java__, , , - "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} __java__ ()\n\ -Undocumented internal function.\n\ -@end deftypefn") -{ - return octave_value (); -} - -DEFUN_DLD (java_convert_matrix, args, nargout, +DEFUN (java_convert_matrix, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} java_convert_matrix ()\n\ Query or set the internal variable that determines FIXME.\n\ @@ -1751,7 +1715,7 @@ return SET_INTERNAL_VARIABLE (java_convert_matrix); } -DEFUN_DLD (java_unsigned_conversion, args, nargout, +DEFUN (java_unsigned_conversion, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} java_unsigned_conversion ()\n\ Query or set the internal variable that determines FIXME.\n\ @@ -1760,7 +1724,7 @@ return SET_INTERNAL_VARIABLE (java_unsigned_conversion); } -DEFUN_DLD (java_debug, args, nargout, +DEFUN (java_debug, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} java_debug ()\n\ Query or set the internal variable that determines FIXME.\n\
rename from libinterp/dldfcn/__java__.h rename to libinterp/octave-value/ov-java.h --- a/libinterp/dldfcn/__java__.h +++ b/libinterp/octave-value/ov-java.h @@ -20,8 +20,8 @@ */ -#if !defined (octave___java__h) -#define octave___java__h 1 +#if !defined (octave_java_h) +#define octave_java_h 1 #include <jni.h> @@ -321,4 +321,4 @@ std::string java_type; }; -#endif /* __JAVA__H__ */ +#endif
--- a/run-octave.in +++ b/run-octave.in @@ -80,6 +80,7 @@ OCTAVE_SITE_INITFILE="$top_srcdir/scripts/startup/main-rcfile" \ OCTAVE_DEFAULT_QT_SETTINGS="$top_srcdir/libgui/default-qt-settings" \ +OCTAVE_JAVA_DIR="$builddir/scripts/java" \ exec $builddir/libtool --mode=execute $driver \ "$octave_executable" --no-init-path --path="$LOADPATH" \ --image-path="$IMAGEPATH" --doc-cache-file="$DOCFILE" \
--- a/scripts/java/org/octave/Octave.java +++ b/scripts/java/org/octave/Octave.java @@ -20,11 +20,6 @@ public class Octave { - static - { - System.load (System.getProperty ("octave.java.path") + java.io.File.separator + "__java__.oct"); - } - private static Object notifyObject = null; private static Object[] args = null; private static LinkedList invokeList = new LinkedList();
--- a/scripts/java/org/octave/OctaveReference.java +++ b/scripts/java/org/octave/OctaveReference.java @@ -18,11 +18,6 @@ public class OctaveReference { - static - { - System.load (System.getProperty ("octave.java.path") + java.io.File.separator + "__java__.oct"); - } - private int ID; public OctaveReference(int ID)