1 //////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (C) 2007-2021 The Octave Project Developers 4 // 5 // See the file COPYRIGHT.md in the top-level directory of this 6 // distribution or <https://octave.org/copyright/>. 7 // 8 // This file is part of Octave. 9 // 10 // Octave is free software: you can redistribute it and/or modify it 11 // under the terms of the GNU General Public License as published by 12 // the Free Software Foundation, either version 3 of the License, or 13 // (at your option) any later version. 14 // 15 // Octave is distributed in the hope that it will be useful, but 16 // WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of the GNU General Public License 21 // along with Octave; see the file COPYING. If not, see 22 // <https://www.gnu.org/licenses/>. 23 // 24 //////////////////////////////////////////////////////////////////////// 25 26 package org.octave; 27 28 import java.io.File; 29 30 public class OctClassLoader extends java.net.URLClassLoader 31 { OctClassLoader()32 public OctClassLoader () 33 { 34 super (new java.net.URL[0]); 35 } 36 OctClassLoader(ClassLoader parent)37 public OctClassLoader (ClassLoader parent) 38 { 39 super (new java.net.URL[0], parent); 40 } 41 findClass(String name)42 protected Class findClass (String name) throws ClassNotFoundException 43 { 44 //System.out.println ("Looking for class " + name); 45 return super.findClass (name); 46 } 47 findLibrary(String libname)48 protected String findLibrary (String libname) 49 { 50 // Look dynamically into java.library.path, because Sun VM does 51 // not do it (seems to cache initial java.library.path instead) 52 53 String[] paths = System.getProperty ("java.library.path").split (File.pathSeparator); 54 55 libname = System.mapLibraryName (libname); 56 for (int i = 0; i < paths.length; i++) 57 { 58 File f = new File (paths[i], libname); 59 if (f.exists ()) 60 return f.getAbsolutePath (); 61 } 62 63 return null; 64 } 65 addClassPath(String name)66 public void addClassPath (String name) throws Exception 67 { 68 java.io.File f = new java.io.File (name); 69 addURL (f.toURI ().toURL ()); 70 } 71 72 // new -MH- addURL(java.net.URL url)73 public void addURL (java.net.URL url) 74 { 75 super.addURL (url); 76 } 77 } 78