Changes 1-September-2010 ---------------------- - src/__java__.cc - code duplication for javaObject and javaMethod unified Changes 30-August-2010 ---------------------- - javaaddclasspath modified to handle tilde notation for user home directory - javarmclasspath modified to handle tilde notation for user home directory - docs updated accordingly ./doc - files octave-java.texi, octave-java.info, octave-java.pdf replaced ./inst - files doc.info replaced - handling of chars and strings in interface match modified: ********************************************************************************************************* Java distinguishes betwen Character and String: a Character is a single Character, while a String is a sequence of one or more Characters. Octave, on the other hand, does not make this distinction, that is ischar('A') and ischar('ABC') both return 1. Strings in Octave are arrays of characters but isvector('A') as well as isvector('ABC') both return 1. The current (1.2.7) implentation of the java package contains a signature matching algoritm for methods, which matches strings with characters. This is okay, as long as a method does not exist with signatures which differ only in String versus Character arguments. The matching algorithm usually finds the method with the Character signature first and later the cast fails because the expected single character does not compatible with the supplied String. A typical example is the StringBuffer class, where the insert method for cCharacters and Strings is implemented in several ways: java.lang.StringBuffer insert(int, char) java.lang.StringBuffer insert(int, java.lang.CharSequence) java.lang.StringBuffer insert(int, char[]) java.lang.StringBuffer insert(int, java.lang.String) The current (1.2.7) implentation of the java package always matches the first sugnature java.lang.StringBuffer insert(int, char) even if a String is supplied. Therefore a call like sb.insert(5,'inserted string'); fails by design, only the single Character variant sb.insert(5,'i'); works. Therefore I have modified the method isCallableFrom in ClassHelper.java so that it does not match String with Character anymore, but only Character with Character and String with String. A new method isStringClass has been added too. private static boolean isCallableFrom ( Class expCls, Class argCls ) ... else if ( isCharClass ( expCls ) && argCls.equals ( Character.class ) ) { /* modified into a more strict check to avoid char to string matching to avoid matching method signatures like java_method(char) with octave_call('a String') Date: 28-08-2010 Author: Martin Hepperle */ return true; } else if ( isStringClass ( expCls ) && argCls.equals ( String.class ) ) { /* added for strict String to String matching java_method(String) with octave_call('a String') but not java_method(char) with octave_call('a String') Date: 28-08-2010 Author: Martin Hepperle */ return true; } ... /** * Check whether the supplied class is a String class. * * Added for more strict char/string mathicng of method signatures * Date: 28-08-2010 * Author: Martin Hepperle * @param cls Class - the class to check * @return boolean - true if clas is of class java.lang.String */ private static boolean isStringClass ( Class cls ) { return ( cls.equals ( String.class ) ); } ... I am not sure whether this breaks anything else - my test cases work fine, but I do not have an extensive test matrix. The following works with the modified version, but doe not with java-1.2.7 sb = javaObject('java.lang.StringBuffer','initial string'); sb.insert(0,'This is the '); sb.toString() ans = This is the initial string ********************************************************************************************************* Changes 26-August-2010 ---------------------- - extension of static classpath via classpath.txt added. Files are searched in user home and in package installation directory. - javaclasspath modified to show static and dynamic classpath like Matlab Changes 26-August-2010 ---------------------- - docs updated: ...dlg functions added under category 'Dialog Boxes' ./doc - files octave-java.texi, octave-java.info, octave-java.pdf replaced ./inst - files doc.info replaced ./src/org/octave/TeXtranslator.java - replaced to remove deadlock when user entered a nonexistent TeX symbol code.