# HG changeset patch
# User Ernst Reissner <rei3ner@arcor.de>
# Date 1470242637 -7200
#      Wed Aug 03 18:43:57 2016 +0200
# Node ID 94ccec9b749d28727066d7216b8df30071076c7c
# Parent  46b67f1569b58c7ce95a357b51afb710b279a8aa
part of java sources: added doxygen comments,
simplified code without really changing behavior,
just strengthened declaration of Throwables.

diff -r 46b67f1569b5 -r 94ccec9b749d scripts/java/org/octave/ClassHelper.java
--- a/scripts/java/org/octave/ClassHelper.java	Wed Aug 03 04:55:05 2016 +0100
+++ b/scripts/java/org/octave/ClassHelper.java	Wed Aug 03 18:43:57 2016 +0200
@@ -22,124 +22,276 @@
 
 package org.octave;
 
-import java.lang.reflect.*;
+import java.net.URL;
+import java.net.URISyntaxException;
+import java.net.MalformedURLException;
 
+import java.io.File;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
+
+//! Collection of methods being the core of the octave functions
+//! forming Octave's Java Interface.
+//!
+//! @arg
+//! #addClassPath(String) used by @file javaaddpath.m defining @c javaaddpath.
+//! @arg
+//! #removeClassPath(String) used by @file javarmpath.m defining @c javarmpath.
+//! @arg
+//! #getClassPath() used by @file javaclasspath.m defining @c javaclasspath
+//! to obtain the dynamic classpath.
+//! @arg
+//! #getMethods(String), #getMethods(Object) and #getMethods(Class)
+//! used by @file methods.m defining @c methods.
+//! @arg
+//! #getFields(Class), #getFields(String) and #getFields(Object)
+//! used by @file fieldnames.m defining @c fieldnames.
+//! @arg
+//! #invokeMethod(Object, String, Object[], Class[]) and
+//! #invokeStaticMethod(String, String, Object[], Class[])
+//! used by <code>javaMethod</code> defined in @file ov-java.cc
+//! defining @c javaMethod.
+//! @arg
+//! #invokeConstructor(String, Object[], Class[])
+//! used by @c javaObject defined in @file ov-java.cc
+//! defining @c javaObject.
+//! @arg
+//! #getField(Object, String), #getStaticField(String, String)
+//! used by @c __java_get__ defined in @file ov-java.cc
+//! used by @file java_get.m defining @c java_get.
+//! @arg
+//! #setField(Object, String, Object), #setStaticField(String, String, Object)
+//! used by @c __java_set__ defined in @file ov-java.cc
+//! used by @file java_set.m defining @c java_set.
+//! @arg
+//! #arraySubsref(Object, int[][]), #arraySubsasgn(Object, int[][], Object)
+//! defining read and write access
+//! through operators <code>.</code> and <code>(...)</code>
+//! @arg
+//! #createArray(Object, int[])
+//! used by @file javaArray.m defining @c javaArray.
 public class ClassHelper
 {
+  //! The loader for the dynamic classpath 
+  //! delegating to the loader for the static classpath. 
   private static OctClassLoader loader;
 
   static
   {
-    ClassLoader l = ClassHelper.class.getClassLoader ();
-    loader = (l instanceof OctClassLoader ? (OctClassLoader) l :
-              new OctClassLoader (l));
+    loader = octClsLoader();
   }
 
+  //! Returns either the class loader of this class
+  //! or creates an @ref OctClassLoader
+  //! with the former classloader as parent.
+  private static OctClassLoader octClsLoader() {
+    ClassLoader l = ClassHelper.class.getClassLoader ();
+    return l instanceof OctClassLoader 
+      ? (OctClassLoader) l 
+      : new OctClassLoader (l);
+  }
 
-  /**
-   * Add the given path to the classpath.
-   * @param name String - path to addd to the classpath
-   * @return boolean - true if the given path exists and was added to the classpath.
-   * @throws Exception
-   */
-  public static boolean addClassPath (String name)
-    throws Exception
+  //! Add the given path @c path to the (dynamic) classpath.
+  //! Used by @file javaaddpath.m only.
+  //!
+  //! @param path 
+  //!    path to add to the classpath.
+  //!    This could be e.g. (examples for Unix)
+  //!    <code>/home/charles</code>, <code>~/Octave</code>
+  //!    or <code>../Software</code>.
+  //! @return 
+  //!    whether the given path exists and was thus added to the classpath.
+  //! @throws MalformedURLException
+  //!    if conversion from URI representing @c path to URL fails. 
+  //!    This should not occur if @c path points to a file.
+  public static boolean addClassPath (String path)
+    throws MalformedURLException
+  {
+    File f = new File (path);
+    if (f.exists ())
+      {
+//        loader.addClassPath (path);
+        // file2url may throw MalformedURLException
+        loader.addURL (file2url(f));
+        return true;
+      }
+    return false;
+  }
+
+  //! Remove the given path @c path from the (dynamic) classpath,
+  //! even if it occurs more than once.
+  //! Used by @file javarmpath.m only.
+  //!
+  //! @param path
+  //!    path to remove from classpath.
+  //! @return
+  //!    whether the given path existed in the classpath before it was removed.
+  //! @throws MalformedURLException
+  //!    if conversion from URI representing @c path to URL fails.
+  //!    This should not occur if @c path points to a file.
+    public static boolean removeClassPath (String path)
+    throws MalformedURLException
   {
     boolean found = false;
-    java.io.File f = new java.io.File (name);
-    if (f.exists ())
-      {
-        loader.addClassPath (name);
-        found = true;
-      }
-    return (found);
-  }
+    // file2url may throw MalformedURLException
+    URL urlToRemove = file2url (new File (path));
+    // save urls in current class path
+    URL[] urls = loader.getURLs ();
 
+    // create a completely new class loader
+    // because URLClassLoader has no removeClassPath() method
+    // FIXME: does not work if ClassHelper.class.getClassLoader()
+    // is already an instance of OctClassLoader which seems true.
+    loader = octClsLoader();
 
-  // new -MH-
-  /**
-   *
-   * @param name String - path to remove from classpath.
-   * @return boolean - true if the given path existed in the classpath before it was removed.
-   * @throws Exception
-   */
-  public static boolean removeClassPath (String name)
-    throws Exception
-  {
-    boolean found = false;
-    java.io.File f = new java.io.File (name);
-    java.net.URL urlToRemove = f.toURI ().toURL ();
-    // save urls in current class path
-    java.net.URL[] urls = loader.getURLs ();
-
-    // create a completely new class loader because java.net.URLClassLoader has no removeClassPath() method
-    ClassLoader l = ClassHelper.class.getClassLoader ();
-    loader = (l instanceof OctClassLoader ? (OctClassLoader) l :
-              new OctClassLoader (l));
-
-    // add the previous urls back, except for the one
+    // add the previous urls back to loader, except for urlToRemove
     for (int i = 0; i < urls.length; i++)
       {
-        java.net.URL url = urls[i];
-        if (!url.equals (urlToRemove))
-          {
-            loader.addURL (url);
-          }
-        else
+        URL url = urls[i];
+        if (url.equals (urlToRemove))
           {
             // path to remove
             found = true;
           }
-      }
+        else
+          {
+            // path to be re-added
+            loader.addURL (url);
+          }
+       }
 
-    return (found);
+    return found;
   }
 
-
-  public static String getClassPath ()
+  //! Return the current dynamic classpath.
+  //! Used by @file javaclasspath.m only.
+  //!
+  //! @return
+  //!    the current dynamic classpath.
+  //!    as a string, separated by the path separator
+  //!    determined by System::getProperty(String).
+  //! @throws URISyntaxException
+  //!    if one of the URLs of the classpath is no URI.
+  //!    This should not occur,
+  //!    because the URLs of #loader come from filenames.
+  public static String getClassPath () throws URISyntaxException
   {
     StringBuffer buf = new StringBuffer ();
     String pathSep = System.getProperty ("path.separator");
-    java.net.URL[] urls = loader.getURLs ();
+    URL[] urls = loader.getURLs ();
 
     for (int i = 0; i < urls.length; i++)
       {
-        try
+        if (i > 0)
           {
-            java.io.File f = new java.io.File (urls[i].toURI ());
-            if (buf.length () > 0)
-              {
-                buf.append (pathSep);
-              }
-            buf.append (f.toString ());
+            buf.append (pathSep);
           }
-        catch (java.net.URISyntaxException ex)
-          {}
+        // url2file may throw URISyntaxException
+        buf.append (url2file(urls[i]).toString ());
       }
     return buf.toString ();
   }
 
+  //! Convert an URL into an according file.
+  //!
+  //! @param url
+  //!    the URL to be converted.
+  //!    This shall be with protocol @c file.
+  //! @throws URISyntaxException
+  //!    If the URL is not an URI.
+  //!    For URLs with protocol @c file, this cannot occur.
+  //! @see ::getClassPath()
+  private static File url2file(URL url) throws URISyntaxException
+  {
+    // toURI() may throw URISyntaxException
+    return new File (url.toURI ());
+  }
+
+  //! Convert a file into an according URL.
+  //!
+  //! @param file
+  //!    the file to be converted.
+  //!    This could be e.g. (examples for Unix)
+  //!    <code>/home/charles</code>, <code>~/Octave</code>
+  //!    or <code>../Software</code>.
+  //! @return
+  //!    For the above input the return is
+  //!    <code>file:/home/charles</code>,
+  //!    <code>file:/home/charles/curr/~/Octave</code>
+  //!    and <code>file:/home/charles/curr/../Software</code>,
+  //!    where <code>/home/charles/curr</code>
+  //!    is the current working directory.
+  //! @throws MalformedURLException
+  //!    With the input specified above, this shall not occur
+  //!    because the intermediate URI has the form
+  //!    For URLs referring to a file, this canot occur.
+  //! @see ::addClassPath(String)
+  //! @see ::removeClassPath(String)
+  private static URL file2url(File file) throws MalformedURLException
+  {
+    // toURL() may throw MalformedURLException
+    return file.toURI ().toURL ();
+  }
+
 
   // new -MH-
-  // return list of methods for given class name
+  //! Return a list of public methods
+  //! of the class with the given class name @c classname
+  //! loaded with #loader.
+  //! This method is based on ::getMethods(Class).
+  //! Used by @file methods.m only.
+  //!
+  //! @param classname
+  //!    the name of the class under consideration.
+  //! @return
+  //!    see ::getMethods(Class).
+  //! @throws ClassNotFoundException
+  //!    if #loader cannot find a class with name @c classname.
   public static String getMethods (String classname)
     throws ClassNotFoundException
   {
-    return (getMethods (Class.forName (classname)));
+    return getMethods (Class.forName (classname));
+    // FIXME: ****
+    //return getMethods (Class.forName (classname, true, loader));
   }
 
 
   // new -MH-
-  // return list of methods for given class instance
+  //! Return a list of public methods
+  //! of the class of the instance @c obj.
+  //! Used by @file methods.m only.
+  //!
+  //! @param obj
+  //!    the object under consideration. This shall not be @c null.
+  //! @throws ClassNotFoundException
+  //!    if #loader cannot find @c obj's class.
+  //!    Since all objects are created by reflection
+  //!    from classes loaded by #loader, this shall not happen.
   public static String getMethods (Object obj)
     throws ClassNotFoundException
   {
-    return (getMethods (obj.getClass ()));
+    return getMethods (obj.getClass ());
   }
 
 
   // new -MH-
-  // return list of methods for given class
+  //! Return list of public
+  //! methods for given class @c klass.
+  //! This method is based on Class::getMethods().
+  //! To obtain all methods, one could use Class::getDeclaredMethods()
+  //! iterating over class and superclasses.
+  //! Used internally and by @file methods.m only.
+  //!
+  //! @param klass
+  //!    the class under consideration.
+  //! @return
+  //!    the list of methods for given class @c klass as a string, 
+  //!    the signatures of the methods separated by <code>;</code>.
   public static String getMethods (Class klass)
   {
     StringBuffer sb = new StringBuffer ();
@@ -149,13 +301,16 @@
       {
         if (i > 0)
           {
-            sb.append (";");
+            sb.append (';');
           }
+
+        // Return type and name 
         sb.append (theMethod[i].getReturnType ().getCanonicalName ());
-        sb.append (" ");
+        sb.append (' ');
         sb.append (theMethod[i].getName ());
-        sb.append ("(");
 
+        // parameter list 
+        sb.append ('(');
         Class theParameter[] = theMethod[i].getParameterTypes ();
         for (int j = 0; j < theParameter.length; j++)
           {
@@ -165,29 +320,40 @@
               }
             sb.append (theParameter[j].getCanonicalName ());
           }
-        sb.append (")");
+        sb.append (')');
 
+        // exceptions 
         Class theExceptions[] = theMethod[i].getExceptionTypes ();
         if (theExceptions.length > 0)
           {
             sb.append (" throws ");
-            for (int j = 0; j < theExceptions.length; j++)
+            sb.append (theExceptions[0].getCanonicalName ());
+             for (int j = 1; j < theExceptions.length; j++)
               {
-                if (j > 0)
-                  {
-                    sb.append (", ");
-                  }
+                sb.append (", ");
                 sb.append (theExceptions[j].getCanonicalName ());
               }
           }
       }
 
-    return (sb.toString ());
+    return sb.toString ();
   }
 
 
   // new -MH-
-  // return list of fields for given class
+  //! Return a list of all accessible public fields
+  //! of the given class @c klass.
+  //! This method is based on Class::getFields().
+  //! To obtain all fields, one could use Class::getDeclaredFields()
+  //! iterating over class and superclasses.
+  //! Used internally and by @file fieldnames.m only.
+  //!
+  //! @param klass
+  //!    the class under consideration.
+  //! @return 
+  //!    the list of names of accessible public fields
+  //!    of the given class @c klass
+  //!    as a string, separated by <code>;</code>.
   public static String getFields (Class klass)
   {
     StringBuffer sb = new StringBuffer ();
@@ -197,40 +363,78 @@
       {
         if (i > 0)
           {
-            sb.append (";");
+            sb.append (';');
           }
         sb.append (theField[i].getName ());
       }
 
-    return (sb.toString ());
+    return sb.toString ();
   }
 
 
   // new -MH-
-  // return list of fields for given class name
+  //! Return a list of all accessible public fields
+  //! of the class with the given class name @c classname
+  //! loaded with #loader.
+  //! This method is based on ::getFields(Class).
+  //! Used by @file fieldnames.m only.
+  //!
+  //! @param classname
+  //!    the name of the class under consideration.
+  //! @return
+  //!    see ::getFields(Class).
+  //! @throws ClassNotFoundException
+  //!    if #loader cannot find a class with name @c classname.
   public static String getFields (String classname)
     throws ClassNotFoundException
   {
-    return (getFields (Class.forName (classname)));
+    return getFields (Class.forName (classname));
+//    return getFields (Class.forName (classname, true, loader));
   }
 
 
   // new -MH-
-  // return list of fields for given class instance
+  //! Return a list of all accessible public fields
+  //! of class of the instance @c obj.
+  //! This method is based on ::getFields(Class).
+  //! Used by @file fieldnames.m only.
+  //!
+  //! @param obj
+  //!    the object under consideration. This shall not be @c null.
+  //! @throws ClassNotFoundException
+  //!    if #loader cannot find @c obj's class.
+  //!    Since all objects are created by reflection
+  //!    from classes loaded by #loader, this shall not happen.
   public static String getFields (Object obj)
     throws ClassNotFoundException
   {
     return (getFields (obj.getClass ()));
   }
 
-
-  public static Method findMethod (Class cls, String name, Class[] argTypes)
+  //! Return the first method in class @c cls
+  //! with name @c name and parameter types @c argTypes
+  //! or @c null if no such method is found.
+  //! Note that if there are more than one method fitting the criteria,
+  //! an arbitrary one is returned, and there is no notification,
+  //! that the solution is not unique.
+  //!
+  //! @param cls
+  //!    the class of the method.
+  //! @param name
+  //!    the name of the method.
+  //! @param argTypes
+  //!    the argument types of the method.
+  //! @return
+  //!    a method in class @c cls
+  //!    with name @c name and parameter types @c argTypes
+  //!    or @c null if no such method exists.
+  private static Method findMethod (Class cls, String name, Class[] argTypes)
   {
     try
       {
         return cls.getMethod (name, argTypes);
       }
-    catch (Exception e)
+    catch (NoSuchMethodException e)
       {
         Method[] mList = cls.getMethods ();
         Method m;
@@ -248,14 +452,28 @@
       }
   }
 
-
-  public static Constructor findConstructor (Class cls, Class[] argTypes)
+  //! Return the first constructor in class @c cls
+  //! with parameter types @c argTypes
+  //! or @c null if no such constructor is found.
+  //! Note that if there are more than one constructor fitting the criteria,
+  //! an arbitrary one is returned, and there is no notification,
+  //! that the solution is not unique.
+  //!
+  //! @param cls
+  //!    the class of the constructor.
+  //! @param argTypes
+  //!    the argument types of the constructor.
+  //! @return
+  //!    a constructor in class @c cls
+  //!    with parameter types @c argTypes
+  //!    or @c null if no such constructor exists.
+  private static Constructor findConstructor (Class cls, Class[] argTypes)
   {
     try
       {
         return cls.getConstructor (argTypes);
       }
-    catch (Exception e)
+    catch (NoSuchMethodException e)
       {
         Constructor[] cList = cls.getConstructors ();
         //System.out.println("# constructors: " + cList.length);
@@ -274,148 +492,211 @@
       }
   }
 
-
-  private static Object invokeMethod (Method m, Object target, Object[] args)
-    throws Exception
+  //! Invoke method @c mthd on the object @c target with arguments @c args. 
+  //!
+  //! @param mthd
+  //!    the method to be invoked.
+  //! @param target
+  //!    the object @c mthd may be invoked on.
+  //!    For static methods this may be @c null.
+  //!    The type must fit the method.
+  //! @param args
+  //!    the arguments to invoke @c mthd with.
+  //! @return
+  //!    the return value of method @c mthd
+  //!    if applied to @c target with arguments @c args.
+  //!    For static methods, @c target is ignored.
+  //!    If @c mthd has return type @c void,
+  //!    this method returns @c null.
+  //!    If  @c mthd has other primitive return type,
+  //!    this is boxed to obtain an object before return.
+  //! @throws InvocationTargetException
+  //!    if invocation of the underlying method throws an exception.
+  //! @throws IllegalAccessException
+  //!    if this Method object is enforcing Java language access control
+  //!    and the underlying method is inaccessible.
+  //! @see ::invokeMethod(Object, String, Object[], Class[])
+  private static Object invokeMethod (Method mthd, Object target, Object[] args)
+    throws InvocationTargetException, IllegalAccessException
   {
-    try
+    //if (Modifier.isPublic(mthd.getModifiers()))
+    try 
       {
-        return m.invoke (target, args);
+        // may throw InvocationTargetException, 
+        // but no IllegalAccessException
+        return mthd.invoke (target, args);
       }
     catch (IllegalAccessException ex)
       {
-        String mName = m.getName ();
-        Class[] pTypes = m.getParameterTypes ();
-        Class currClass = target.getClass ();
-
-        while (currClass != null)
+        // FIXME: is this really wanted? 
+        String mName   = mthd.getName ();
+        Class[] pTypes = mthd.getParameterTypes ();
+ 
+        // search in target class and in superclasses. 
+        for (Class currClass = target.getClass ();
+             currClass != null; 
+             currClass = currClass.getSuperclass ())
           {
             try
               {
+                //  may throw NoSuchMethodException
                 Method meth = currClass.getMethod (mName, pTypes);
-                if (!meth.equals (m))
+                if (!meth.equals (mthd))
                   {
+                    // may throw InvocationTargetException, 
+                    // IllegalAccessException
                     return meth.invoke (target, args);
                   }
               }
-            catch (NoSuchMethodException ex2)
-              {}
-            catch (IllegalAccessException ex2)
-              {}
+            catch (NoSuchMethodException ex2) // NOPMD
+              {
+                // empty catch is really ok: just go on searching 
+              }
 
+            // FIXME: I am pretty sure, that this finds no further methods 
+            // and shall thus be removed (ER). 
             Class[] ifaceList = currClass.getInterfaces ();
             for (int i = 0; i < ifaceList.length; i++)
               {
                 try
                   {
+                    //  may throw NoSuchMethodException
                     Method meth = ifaceList[i].getMethod (mName, pTypes);
+                    // may throw InvocationTargetException
                     return meth.invoke (target, args);
                   }
-                catch (NoSuchMethodException ex2)
-                  {}
-                catch (IllegalAccessException ex2)
-                  {}
-              }
+                catch (NoSuchMethodException ex2) // NOPMD
+                  {
+                    // empty catch is really ok: just go on searching 
+                  }
+              } // for 
+          } // for 
+        // throws IllegalAccessException 
+        throw ex;
+     } // catch IllegalAccessException 
+  }
 
-            currClass = currClass.getSuperclass ();
-          }
 
-        throw ex;
+  // Used internally and by 
+  // #do_javaMethod(void*, std::string&, octave_value_list&) 
+  // in <code>ov-java.cc</code> only. 
+  // getField(Object, String)
+  public static Object invokeMethod (Object target, 
+                                     String name,
+                                     Object[] args, 
+                                     Class[] argTypes)
+    throws Throwable
+  {
+    Method m = findMethod (target.getClass (), name, argTypes);
+    if (m == null)
+      {
+        throw new NoSuchMethodException (name);
+      }
+
+    try
+      {
+        Object result = invokeMethod (m, target,
+                                      castArguments (args, argTypes,
+                                                     m.getParameterTypes ()));
+        return result;
+      }
+    catch (InvocationTargetException ex)
+      {
+        throw ex.getCause ();
+      }
+
+  }
+
+  // using loader 
+  // Used internally and by @file ov-java.cc only. 
+  // getStaticField(String, String)
+  public static Object invokeStaticMethod (String cls, 
+                                           String name,
+                                           Object[] args, 
+                                           Class[] argTypes)
+    throws ClassNotFoundException, 
+    NoSuchMethodException, 
+    IllegalAccessException, 
+    Throwable
+  {
+    // forName may throw ClassNotFoundException 
+    Method m = findMethod (Class.forName (cls, true, loader), 
+                           name,
+                           argTypes);
+    if (m == null)
+      {
+        throw new NoSuchMethodException (name);
+      }
+
+    try
+      {
+        // may throw IllegalAccessException, InvocationTargetException
+        Object result = m.invoke (null,
+                                  castArguments (args, argTypes,
+                                                 m.getParameterTypes ()));
+        return result;
+      }
+    catch (InvocationTargetException ex)
+      {
+        // may throw general Throwable 
+        throw ex.getCause ();
       }
   }
 
-
-  public static Object invokeMethod (Object target, String name,
-                                     Object[] args, Class[] argTypes)
-    throws Throwable
-  {
-    Method m = findMethod (target.getClass (), name, argTypes);
-    if (m != null)
-      {
-        try
-          {
-            Object result = invokeMethod (m, target,
-                                          castArguments (args, argTypes,
-                                                         m.getParameterTypes ()));
-            return result;
-          }
-        catch (InvocationTargetException ex)
-          {
-            throw ex.getCause ();
-          }
-      }
-    else
-      {
-        throw new NoSuchMethodException (name);
-      }
-  }
-
-
-  public static Object invokeStaticMethod (String cls, String name,
-                                           Object[] args, Class[] argTypes)
-    throws Throwable
-  {
-    Method m = findMethod (Class.forName (cls, true, loader), name,
-                           argTypes);
-    if (m != null)
-      {
-        try
-          {
-            Object result = m.invoke (null,
-                                      castArguments (args, argTypes,
-                                                     m.getParameterTypes ()));
-            return result;
-          }
-        catch (InvocationTargetException ex)
-          {
-            throw ex.getCause ();
-          }
-      }
-    else
-      {
-        throw new NoSuchMethodException (name);
-      }
-  }
-
-
-  public static Object invokeConstructor (String cls, Object[] args,
+  // using loader 
+  // Used @file ov-java.cc only. 
+  public static Object invokeConstructor (String cls, 
+                                          Object[] args,
                                           Class[] argTypes)
     throws Throwable
   {
     Constructor c = findConstructor (Class.forName (cls, true, loader),
                                      argTypes);
-    if (c != null)
-      {
-        try
-          {
-            Object result = c.newInstance (castArguments (args, argTypes,
-                                                          c.getParameterTypes ()));
-            return result;
-          }
-        catch (InvocationTargetException ex)
-          {
-            throw ex.getCause ();
-          }
-      }
-    else
+    if (c == null)
       {
         throw new NoSuchMethodException (cls);
       }
+
+    try
+      {
+        return c.newInstance (castArguments (args, argTypes,
+                                             c.getParameterTypes ()));
+      }
+    catch (InvocationTargetException ex)
+      {
+        throw ex.getCause ();
+      }
+
   }
 
-
+  //! Return the value of the field with name @c name
+  //! of object @c target.
+  //! Used by @file ov-java.cc only.
+  //!
+  //! @param target
+  //!    an object to query a field which shall not be @c null.
+  //! @param name
+  //!    the name of the field of @c target 
+  //!    which shall not be @c null. 
+  //! @throws NoSuchFieldException 
+  //!    if @c target has no field with the given name.
+  //! @throws IllegalAccessException
+  //!    if the field @c name of object @c target is not accessible. 
   public static Object getField (Object target, String name)
-    throws Throwable
+    throws NoSuchFieldException, IllegalAccessException, Throwable
   {
     try
       {
-        Field f = target.getClass ().getField (name);
-        return f.get (target);
+        // getField may throw NoSuchFieldException 
+        //   if a field with the specified name is not found.
+        // get may throw IllegalAccessException
+        return target.getClass ().getField (name).get (target);
       }
     catch (NoSuchFieldException ex)
       {
         try
           {
+            // may throw Throwable if so does method name() 
             return invokeMethod (target, name, new Object[0], new Class[0]);
           }
         catch (NoSuchMethodException ex2)
@@ -425,17 +706,24 @@
       }
   }
 
-
+  // based on loader 
+  // Used by @file ov-java.cc only. 
   public static Object getStaticField (String cls, String name)
-    throws Throwable
+    throws ClassNotFoundException, 
+    NoSuchFieldException, 
+    IllegalAccessException, 
+    Throwable
   {
     try
       {
-        Field f = Class.forName (cls, true, loader).getField (name);
-        return f.get (null);
+        // getField may throw NoSuchFieldException 
+        //   if a field with the specified name is not found.
+        // get may throw IllegalAccessException
+        return Class.forName (cls, true, loader).getField (name).get (null);
       }
     catch (NoSuchFieldException ex)
       {
+        // FIXME: is this really appropriate? 
         try
           {
             return invokeStaticMethod (cls, name, new Object[0], new Class[0]);
@@ -447,19 +735,25 @@
       }
   }
 
-
+  // Used by @file ov-java.cc only. 
   public static void setField (Object target, String name, Object value)
-    throws Exception
+    throws NoSuchFieldException, IllegalAccessException
   {
+    // getField may throw NoSuchFieldException
     Field f = target.getClass ().getField (name);
+    // set may throw IllegalAccessException 
     f.set (target, castArgument (value, value.getClass (), f.getType ()));
   }
 
-
+  // based on loader 
+  // Used by @file ov-java.cc only. 
   public static void setStaticField (String cls, String name, Object value)
-    throws Exception
+    throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
   {
+    // forName may throw ClassNotFoundException 
+    // getField may throw NoSuchFieldException
     Field f = Class.forName (cls, true, loader).getField (name);
+    // set may throw IllegalAccessException 
     f.set (null, castArgument (value, value.getClass (), f.getType ()));
   }
 
@@ -497,18 +791,21 @@
     //System.out.println("isCallableFrom: "+expCls.getCanonicalName() + " <=? " + argCls.getCanonicalName());
     if (argCls == null)
       {
-        return!expCls.isPrimitive ();
+        return !expCls.isPrimitive ();
       }
-    else if (expCls.isAssignableFrom (argCls))
+
+    if (expCls.isAssignableFrom (argCls))
       {
         return true;
       }
-    else if ((isNumberClass (expCls) || isBooleanClass (expCls))
+
+    if ((isNumberClass (expCls) || isBooleanClass (expCls))
              && isNumberClass (argCls))
       {
         return true;
       }
-    else if (isCharClass (expCls) && argCls.equals (Character.class))
+
+   if (isCharClass (expCls) && argCls.equals (Character.class))
       {
         /*
           modified into a more strict check to avoid char to string matching
@@ -519,7 +816,8 @@
         */
         return true;
       }
-    else if (isStringClass (expCls) && argCls.equals (String.class))
+
+    if (expCls.equals (String.class) && argCls.equals (String.class))
       {
         /*
           added for strict String to String matching
@@ -531,63 +829,57 @@
         */
         return true;
       }
-    else if (expCls.isArray () && argCls.isArray ()
+
+    if (expCls.isArray () && argCls.isArray ()
              && isCallableFrom (expCls.getComponentType (),
                                 argCls.getComponentType ()))
       {
         return true;
       }
-    else if (expCls.equals (Object.class) && argCls.isPrimitive ())
-      {
-        return true;
-      }
-    else
-      {
-        return false;
-      }
+    
+    return expCls.equals (Object.class) && argCls.isPrimitive ();
+
   }
 
 
   private static boolean isNumberClass (Class cls)
   {
-    return (cls.equals (Integer.TYPE) || cls.equals (Integer.class)
-            || cls.equals (Short.TYPE) || cls.equals (Short.class)
-            || cls.equals (Long.TYPE) || cls.equals (Long.class)
-            || cls.equals (Float.TYPE) || cls.equals (Float.class)
-            || cls.equals (Double.TYPE) || cls.equals (Double.class));
+    // FIXME: seems as if Byte is missing. 
+    return cls.equals (Short.TYPE  ) || cls.equals (Short.class  )
+      ||   cls.equals (Integer.TYPE) || cls.equals (Integer.class)
+      ||   cls.equals (Long.TYPE   ) || cls.equals (Long.class   )
+      ||   cls.equals (Float.TYPE  ) || cls.equals (Float.class  )
+      ||   cls.equals (Double.TYPE ) || cls.equals (Double.class );
   }
 
 
   private static boolean isBooleanClass (Class cls)
   {
-    return (cls.equals (Boolean.class) || cls.equals (Boolean.TYPE));
+    return cls.equals (Boolean.class) || cls.equals (Boolean.TYPE);
   }
 
 
   private static boolean isCharClass (Class cls)
   {
-    return (cls.equals (Character.class) || cls.equals (Character.TYPE));
+    return cls.equals (Character.class) || cls.equals (Character.TYPE);
   }
 
 
-  /**
-   * 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)
-            );
-  }
+  //   //  * Check whether the supplied class is a String class.
+  //  *
+  //  * Added for more strict char/string matching 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);
+  // }
 
 
-  private static Object[] castArguments (Object[] args, Class[] argTypes,
+  private static Object[] castArguments (Object[] args, 
+                                         Class[] argTypes,
                                          Class[] expTypes)
   {
     for (int i = 0; i < args.length; i++)
@@ -597,43 +889,51 @@
     return args;
   }
 
-
+  // FIXME: simply null if no success. 
+  // To be analyzed: isn't type just obj.getClass()? 
   private static Object castArgument (Object obj, Class type, Class expType)
   {
-    // System.out.println("expType:"+expType.getCanonicalName() + " <= type:" + type.getCanonicalName());
     if (type == null || expType.isAssignableFrom (type))
       {
         return obj;
       }
-    else if (isNumberClass (expType))
+    if (isNumberClass (expType))
       {
+        Number num = (Number)obj;
+        // FIXME: what if obj is null? 
+        // FIXME: seems as if Byte is missing as in isNumberClass 
+        if (expType.equals (Short.TYPE) || expType.equals (Short.class))
+          {
+            return Short  .valueOf(num. shortValue());
+          }
         if (expType.equals (Integer.TYPE) || expType.equals (Integer.class))
           {
-            return new Integer (((Number) obj).intValue ());
+            return Integer.valueOf(num.   intValue());
           }
-        else if (expType.equals (Double.TYPE) || expType.equals (Double.class))
+        if (expType.equals (Long.TYPE) || expType.equals (Long.class))
           {
-            return new Double (((Number) obj).doubleValue ());
+            return Long   .valueOf(num.  longValue());
           }
-        else if (expType.equals (Short.TYPE) || expType.equals (Short.class))
+        if (expType.equals (Float.TYPE) || expType.equals (Float.class))
           {
-            return new Short (((Number) obj).shortValue ());
+            return Float  .valueOf(num. floatValue());
           }
-        else if (expType.equals (Long.TYPE) || expType.equals (Long.class))
+        if (expType.equals (Double.TYPE) || expType.equals (Double.class))
           {
-            return new Long (((Number) obj).longValue ());
+            return Double .valueOf(num.doubleValue());
           }
-        else if (expType.equals (Float.TYPE) || expType.equals (Float.class))
-          {
-            return new Float (((Number) obj).floatValue ());
-          }
+        throw new IllegalStateException
+          ("Missing branch for byte? found "+expType);
       }
-    else if (isBooleanClass (expType))
+    if (isBooleanClass (expType))
       {
-        return new Boolean (((Number) obj).intValue () != 0);
+        // FIXME: what if obj is null? 
+        // FIXME: why is obj a Number here?? 
+        return Boolean.valueOf(((Number) obj).intValue () != 0);
       }
-    else if (isCharClass (expType))
+    if (isCharClass (expType))
       {
+        // FIXME: what if obj is null? 
         String s = obj.toString ();
         if (s.length () != 1)
           {
@@ -641,22 +941,37 @@
           }
         return new Character (s.charAt (0));
       }
-    else if (expType.isArray () && type.isArray ())
+    if (expType.isArray () && type.isArray ())
       {
-        return castArray (obj, type.getComponentType (),
+        // ensure that cast allows obj==null
+        return castArray (obj, 
+                          type   .getComponentType (),
                           expType.getComponentType ());
       }
-    else if (type.isPrimitive ())
+    if (type.isPrimitive ())
       {
+        // FIXME: appropriate?
         return obj;
       }
     return null;
   }
 
-
-  private static Object castArray (Object obj, Class elemType,
+  //! Cast the given array @c obj componentwise
+  //! from class @c elemType to @c elemExpType.
+  //!
+  //! @param obj
+  //!    the instance of an array.
+  //! @param elemType
+  //!    @c obj's class
+  //! @param elemExpType
+  //!    the target class to cast the entries of @c obj.
+  //! @throws IllegalArgumentException
+  //!    if obj is no array instance.
+  private static Object castArray (Object obj, 
+                                   Class elemType,
                                    Class elemExpType)
   {
+    // throws IllegalArgumentException if obj is not an array instance
     int len = Array.getLength (obj);
     Object result = Array.newInstance (elemExpType, len);
     for (int i = 0; i < len; i++)
@@ -668,68 +983,83 @@
   }
 
 
+  //! Return the mathematical dimension of @c cls. 
+  //! This is 0 if @c cls no array type or if @c null. 
   private static int getArrayClassNDims (Class cls)
   {
-    if (cls != null && cls.isArray ())
+    int res = 0;
+    while (cls != null && cls.isArray ()) 
       {
-        return (1 + getArrayClassNDims (cls.getComponentType ()));
+        res++;
+        cls = cls.getComponentType ();
       }
-    else
-      {
-        return 0;
-      }
+    return res;
+
+    // if (cls != null && cls.isArray ())
+    //   {
+    //     return (1 + getArrayClassNDims (cls.getComponentType ()));
+    //   }
+    // else
+    //   {
+    //     return 0;
+    //   }
   }
 
-
+  //! Return the innermost component type of @c cls. 
   private static Class getArrayElemClass (Class cls)
   {
-    if (cls.isArray ())
+
+    while (cls.isArray ()) 
       {
-        return getArrayElemClass (cls.getComponentType ());
+        cls = cls.getComponentType ();
       }
-    else
-      {
-        return cls;
-      }
+    return cls;
+
+
+    // if (cls.isArray ())
+    //   {
+    //     return getArrayElemClass (cls.getComponentType ());
+    //   }
+    // else
+    //   {
+    //     return cls;
+    //   }
   }
 
 
-  private static Object getArrayElements (Object array, int[][] idx,
+  private static Object getArrayElements (Object array, 
+                                          int[][] idx,
                                           int offset,
                                           int ndims, Class elemType)
   {
     if (offset >= ndims)
       {
         Object elem = Array.get (array, idx[offset][0]);
+        return (offset < idx.length - 1)
+          ? getArrayElements (elem, idx, offset + 1, ndims, elemType)
+          : elem;
+      }
+
+    Class compType = elemType.getComponentType ();
+    Object retval = Array.newInstance (compType, idx[offset].length);
+    for (int i = 0; i < idx[offset].length; i++)
+      {
+        Object elem = Array.get (array, idx[offset][i]);
         if (offset < idx.length - 1)
           {
-            return getArrayElements (elem, idx, offset + 1, ndims, elemType);
+            elem = getArrayElements (elem, idx, offset + 1, ndims, compType);
           }
-        else
-          {
-            return elem;
-          }
+        Array.set (retval, i, elem);
       }
-    else
-      {
-        Class compType = elemType.getComponentType ();
-        Object retval = Array.newInstance (compType, idx[offset].length);
-        for (int i = 0; i < idx[offset].length; i++)
-          {
-            Object elem = Array.get (array, idx[offset][i]);
-            if (offset < idx.length - 1)
-              {
-                elem = getArrayElements (elem, idx, offset + 1, ndims, compType);
-              }
-            Array.set (retval, i, elem);
-          }
-        return retval;
-      }
+    return retval;
+
   }
 
-
-  public static Object arraySubsref (Object obj, int[][] idx)
-    throws Exception
+  // Used by 
+  // #get_array_elements(JNIEnv*, jobject, octave_value_list&) 
+  // in @file ov-java.cc only and is recursive. 
+  //PMD: has an NPath complexity of 582
+  public static Object arraySubsref (Object obj, int[][] idx) // NOPMD
   {
     if (!obj.getClass ().isArray ())
       {
@@ -754,69 +1084,71 @@
             return retval;
           }
       }
-    else
+
+
+    int[] dims = new int[idx.length];
+    for (int i = 0; i < idx.length; i++)
       {
-        int[] dims = new int[idx.length];
-        for (int i = 0; i < idx.length; i++)
+        dims[i] = idx[i].length;
+      }
+
+    if (dims.length != getArrayClassNDims (obj.getClass ()))
+      {
+        throw new IllegalArgumentException ("index size mismatch");
+      }
+
+    /* resolve leading singletons */
+    Object theObj = obj;
+    int offset = 0;
+    while (dims[offset] == 1)
+      {
+        theObj = Array.get (theObj, idx[offset][0]);
+        offset = offset + 1;
+        if (offset >= dims.length)
           {
-            dims[i] = idx[i].length;
+            return theObj;
           }
+      }
+    if (offset > 0)
+      {
+        int[][] new_idx = new int[idx.length - offset][];
+        System.arraycopy (idx, offset, new_idx, 0, idx.length - offset);
+        return arraySubsref (theObj, new_idx);
+      }
 
-        if (dims.length != getArrayClassNDims (obj.getClass ()))
-          {
-            throw new IllegalArgumentException ("index size mismatch");
-          }
+    /* chop trailing singletons */
+    int ndims = dims.length;
+    while (ndims > 1 && dims[ndims - 1] == 1)
+      {
+        ndims--;
+      }
 
-        /* resolve leading singletons */
-        Object theObj = obj;
-        int offset = 0;
-        while (dims[offset] == 1)
-          {
-            theObj = Array.get (theObj, idx[offset][0]);
-            offset = offset + 1;
-            if (offset >= dims.length)
-              {
-                return theObj;
-              }
-          }
-        if (offset > 0)
-          {
-            int[][] new_idx = new int[idx.length - offset][];
-            System.arraycopy (idx, offset, new_idx, 0, idx.length - offset);
-            return arraySubsref (theObj, new_idx);
-          }
+    /* create result array */
+    Class elemClass = theObj.getClass ();
+    for (int i = 0; i <= (dims.length - ndims); i++)
+      {
+        elemClass = elemClass.getComponentType ();
+      }
+    Object retval = Array.newInstance (elemClass, dims[0]);
 
-        /* chop trailing singletons */
-        int ndims = dims.length;
-        while (ndims > 1 && dims[ndims - 1] == 1)
-          {
-            ndims--;
-          }
+    /* fill-in array */
+    for (int i = 0; i < idx[0].length; i++)
+      {
+        Object elem = getArrayElements (Array.get (theObj, idx[0][i]),
+                                        idx, 1, ndims, elemClass);
+        Array.set (retval, i, elem);
+      }
 
-        /* create result array */
-        Class elemClass = theObj.getClass ();
-        for (int i = 0; i <= (dims.length - ndims); i++)
-          {
-            elemClass = elemClass.getComponentType ();
-          }
-        Object retval = Array.newInstance (elemClass, dims[0]);
+    return retval;
 
-        /* fill-in array */
-        for (int i = 0; i < idx[0].length; i++)
-          {
-            Object elem = getArrayElements (Array.get (theObj, idx[0][i]),
-                                            idx, 1, ndims, elemClass);
-            Array.set (retval, i, elem);
-          }
-
-        return retval;
-      }
   }
 
 
-  private static Object setArrayElements (Object array, int[][] idx,
-                                          int offset, int ndims, Object rhs)
-    throws Exception
+  private static Object setArrayElements (Object array,
+                                          int[][] idx,
+                                          int offset, 
+                                          int ndims, 
+                                          Object rhs)
   {
     if (offset >= ndims)
       {
@@ -831,27 +1163,28 @@
           }
         return array;
       }
-    else
+
+    for (int i = 0; i < idx[offset].length; i++)
       {
-        for (int i = 0; i < idx[offset].length; i++)
+        if (offset < idx.length - 1)
           {
-            if (offset < idx.length - 1)
-              {
-                setArrayElements (Array.get (array, idx[offset][i]), idx,
-                                  offset + 1, ndims, Array.get (rhs, i));
-              }
-            else
-              {
-                Array.set (array, idx[offset][i], Array.get (rhs, i));
-              }
+            setArrayElements (Array.get (array, idx[offset][i]), idx,
+                              offset + 1, ndims, Array.get (rhs, i));
           }
-        return array;
+        else
+          {
+            Array.set (array, idx[offset][i], Array.get (rhs, i));
+          }
       }
+    return array;
   }
 
-
-  public static Object arraySubsasgn (Object obj, int[][] idx, Object rhs)
-    throws Exception
+  // PMD: has an NPath complexity of 294
+  // return value seems superfluous. 
+  // Used by @file ov-java.cc only and is recursive. 
+  public static Object arraySubsasgn (Object obj, // NOPMD
+                                      int[][] idx, 
+                                      Object rhs) 
   {
     if (!obj.getClass ().isArray ())
       {
@@ -862,67 +1195,95 @@
       {
         if (idx[0].length == 1)
           {
+            // throws IllegalArgumentException if obj is not an array 
             Array.set (obj, idx[0][0], rhs);
           }
         else
           {
             for (int i = 0; i < idx[0].length; i++)
               {
+                // throws IllegalArgumentException if obj is not an array 
                 Array.set (obj, idx[0][i], Array.get (rhs, i));
               }
           }
         return obj;
       }
-    else
+
+
+    int[] dims = new int[idx.length];
+    for (int i = 0; i < idx.length; i++)
       {
-        int[] dims = new int[idx.length];
-        for (int i = 0; i < idx.length; i++)
-          {
-            dims[i] = idx[i].length;
-          }
+        dims[i] = idx[i].length;
+      }
 
-        if (dims.length != getArrayClassNDims (obj.getClass ()))
-          {
-            throw new IllegalArgumentException ("index size mismatch");
-          }
+    if (dims.length != getArrayClassNDims (obj.getClass ()))
+      {
+        throw new IllegalArgumentException ("index size mismatch");
+      }
 
-        /* resolve leading singletons */
-        Object theObj = obj;
-        int offset = 0;
-        while (dims[offset] == 1 && offset < (dims.length - 1))
-          {
-            theObj = Array.get (theObj, idx[offset][0]);
-            offset = offset + 1;
-          }
-        if (offset > 0)
-          {
-            int[][] new_idx = new int[idx.length - offset][];
-            System.arraycopy (idx, offset, new_idx, 0, idx.length - offset);
-            arraySubsasgn (theObj, new_idx, rhs);
-            return obj;
-          }
-
-        /* chop trailing singletons */
-        int ndims = dims.length;
-        while (ndims > 1 && dims[ndims - 1] == 1)
-          {
-            ndims--;
-          }
-
-        for (int i = 0; i < idx[0].length; i++)
-          {
-            setArrayElements (Array.get (theObj, idx[0][i]), idx, 1, ndims,
-                              Array.get (rhs, i));
-          }
-
+    /* resolve leading singletons */
+    Object theObj = obj;
+    int offset = 0;
+    while (dims[offset] == 1 && offset < (dims.length - 1))
+      {
+        theObj = Array.get (theObj, idx[offset][0]);
+        offset = offset + 1;
+      }
+    if (offset > 0)
+      {
+        int[][] new_idx = new int[idx.length - offset][];
+        System.arraycopy (idx, offset, new_idx, 0, idx.length - offset);
+        arraySubsasgn (theObj, new_idx, rhs);
         return obj;
       }
+
+    /* chop trailing singletons */
+    int ndims = dims.length;
+    while (ndims > 1 && dims[ndims - 1] == 1)
+      {
+        ndims--;
+      }
+
+    for (int i = 0; i < idx[0].length; i++)
+      {
+        setArrayElements (Array.get (theObj, idx[0][i]), idx, 1, ndims,
+                          Array.get (rhs, i));
+      }
+
+    return obj;
   }
 
-
+  //! Return an array with entry type given by @c cls
+  //! with dimensions given by @c dims.
+  //! The class may be given directly as a @ref Class object
+  //! or as a string via its name.
+  //! Used by @c javaArray only.
+  //!
+  //! @param cls
+  //!    the atomic component class given as a class object or as a string.
+  //!    If given as a string, the class is loaded via #loader.
+  //! @param dims
+  //!    the dimensions which shall be non-negative but less than 256.
+  //! @return
+  //!    an array with the given component type.
+  //!    If @c cls is a string, the class is loaded by #loader.
+  //! @throws ClassNotFoundException
+  //!    if @c cls is a string representing a class name
+  //!    and if #loader could not find the according class.
+  // based on loader but only partially. 
+  // used by javaArray.m
   public static Object createArray (Object cls, int[] dims)
-    throws Exception
+    throws ClassNotFoundException
   {
+    // FIXME: seems as if used in javaArray.m only.  
+    // Then more appropriate seems split into two methods: 
+    // one with cls is a Class other one with cls is a String 
+    // FIXME: if a class is given directly, 
+    // it is not guaranteed, that this is loaded via #loader 
+    // So this shall be fixed. 
+    // Typically, different usages are treated in m file invoking error 
+    // in the last else branch. 
+    // This would be appropriate here also. 
     Class theClass;
     if (cls instanceof Class)
       {
@@ -930,6 +1291,7 @@
       }
     else if (cls instanceof String)
       {
+        // may throw ClassNotFoundException
         theClass = Class.forName ((String) cls, true, loader);
       }
     else
@@ -942,9 +1304,9 @@
   }
 
 
-  public static Object createArray (Object cls, int length)
-    throws Exception
-  {
-    return createArray (cls, new int[] {length});
-  }
+  // public static Object createArray (Object cls, int length)
+  //   throws ClassNotFoundException
+  // {
+  //   return createArray (cls, new int[] {length});
+  // }
 }
diff -r 46b67f1569b5 -r 94ccec9b749d scripts/java/org/octave/OctClassLoader.java
--- a/scripts/java/org/octave/OctClassLoader.java	Wed Aug 03 04:55:05 2016 +0100
+++ b/scripts/java/org/octave/OctClassLoader.java	Wed Aug 03 18:43:57 2016 +0200
@@ -24,16 +24,31 @@
 
 import java.io.File;
 
-public class OctClassLoader extends java.net.URLClassLoader
+import java.net.URL;
+import java.net.URLClassLoader;
+
+//! The system class loader for a Java virtual machines (JVM)
+//! created by Octave
+//! (see method <code>initialize_jvm</code> in <code>ov-java.cc</code>).
+//! This is used to load all classes from the dynamic class path.
+//! It is also used to load classes from the static class path
+//! delegating class loading to the parent classloader.
+//! <p>
+//! Class @ref ClassHelper uses @ref OctClassLoader to load classes
+//! for calling constructors and static methods
+//! and for accessing static fields.
+//! To add an entry of the classpath, invoke ::addURL(URL)
+//! whereas to remove an entry, a new classloader is created.
+public class OctClassLoader extends URLClassLoader
 {
   public OctClassLoader ()
   {
-    super (new java.net.URL[0]);
+    super (new URL[0]);
   }
 
   public OctClassLoader (ClassLoader parent)
   {
-    super (new java.net.URL[0], parent);
+    super (new URL[0], parent);
   }
 
   protected Class findClass (String name) throws ClassNotFoundException
@@ -47,27 +62,30 @@
     // Look dynamically into java.library.path, because Sun VM does
     // not do it (seems to cache initial java.library.path instead)
 
-    String[] paths = System.getProperty ("java.library.path").split (File.pathSeparator);
+    String[] paths = System.getProperty ("java.library.path")
+      .split (File.pathSeparator);
 
     libname = System.mapLibraryName (libname);
     for (int i = 0; i < paths.length; i++)
       {
         File f = new File (paths[i], libname);
         if (f.exists ())
-          return f.getAbsolutePath ();
+          {
+            return f.getAbsolutePath ();
+          }
       }
 
     return null;
   }
 
-  public void addClassPath (String name) throws Exception
-  {
-    java.io.File f = new java.io.File (name);
-    addURL (f.toURI ().toURL ());
-  }
+  // public void addClassPath (String name) throws MalformedURLException
+  // {
+  //   File f = new File (name);
+  //   addURL (f.toURI ().toURL ());
+  // }
 
   // new -MH-
-  public void addURL (java.net.URL url)
+  public void addURL (URL url)
   {
     super.addURL (url);
   }
