* Bug #11567 fixed - Scilab failed to start an accentuated character was present... 47/11047/4
Sylvestre Ledru [Wed, 27 Mar 2013 11:58:23 +0000 (12:58 +0100)]
Change-Id: I59b6ab7442d06c491dcb22f4d5692a8fe44ef2b8

scilab/CHANGES_5.4.X
scilab/modules/jvm/src/java/org/scilab/modules/jvm/LoadClassPath.java

index f610fe4..bf046d6 100644 (file)
@@ -328,6 +328,9 @@ Bug fixes
 
 * Bug #11549 fixed - Preferences window changed its dimension when hitting Default button.
 
+* Bug #11567 fixed - Scilab failed to start an accentuated character was
+                     present in the pathname.
+
 * Bug #11569 fixed - F5 to navigate in the dock was incompatible with SciNotes.
                      So F5 replaced by shift+F6 to go to the previous tab.
 
index 255671a..3e9a7f8 100644 (file)
@@ -14,6 +14,7 @@ package org.scilab.modules.jvm;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.File;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -36,80 +37,83 @@ import org.scilab.modules.commons.xml.ScilabDocumentBuilderFactory;
  * Utility class to ease the jar loading management.
  */
 public final class LoadClassPath {
-       /** Scilab environment variable */
-       private static final String SCI = System.getenv("SCI");
-       /** The classpath.xml file path */
-       private static final String CLASSPATH_PATH = SCI + "/etc/classpath.xml";
-       /** The expression to get the jars */
-       private static final String XPATH_EXPRS = "//classpaths/path[@load='onUse']/load";
-       
-       /** Cache the already loaded libraries */
-       private static Set<String> loadedModules = new HashSet<String>(); 
-       
-       /**
-        * Load the module on the classpath
-        * 
-        * The module have to be declared in the $SCI/etc/classpath.xml file.
-        * 
-        * @param module the module to be loaded
-        */
-       public static void loadOnUse(String module) {
-               if (loadedModules.contains(module)) {
-                       return;
-               }
-               
-               // define XPath expression
-               String xpathExpression = XPATH_EXPRS + "[@on='" + module + "']";
-               
-               // Initialize xpath
-               XPathFactory factory = XPathFactory.newInstance();
-               XPath xpath = factory.newXPath();
-               
-               // initialize document factory
-               DocumentBuilderFactory domFactory = ScilabDocumentBuilderFactory.newInstance();
-               domFactory.setValidating(false);
-           domFactory.setNamespaceAware(true);
-          
-           // Parse Classpath file
-           Document doc = null;
-           try {
-                       DocumentBuilder builder = domFactory.newDocumentBuilder();
-                       doc = builder.parse(CLASSPATH_PATH);
-           } catch (ParserConfigurationException e) {
-                       e.printStackTrace();
-                       return;
-               } catch (SAXException e) {
-                       e.printStackTrace();
-                       return;
-               } catch (IOException e) {
-                       e.printStackTrace();
-                       return;
-               }
-           
-               // Load JARs
-               try {
-                       NodeList result = (NodeList) xpath.evaluate(xpathExpression, doc,
-                                               XPathConstants.NODESET);
-                       
-                       for (int i = 0; i < result.getLength(); i++) {
-                               Node n = result.item(i).getParentNode();
-                               
-                               String jar = n.getAttributes().getNamedItem("value").getNodeValue();
-                               ClassPath.addFile(jar.replace("$SCILAB", SCI), 0);
-                               loadedModules.add(module);
-                       }
-                       
-               } catch (XPathExpressionException e) {
-                       e.printStackTrace();
-               } catch (FileNotFoundException e) {
-                       e.printStackTrace();
-               } catch (IOException e) {
-                       e.printStackTrace();
-               }
-       }
-       
-       /**
-        * This class is a static singleton
-        */
-       private LoadClassPath() { }
+    /** Scilab environment variable */
+    private static final String SCI = System.getenv("SCI");
+    /** The classpath.xml file path */
+    private static final String CLASSPATH_PATH = SCI + "/etc/classpath.xml";
+    /** The expression to get the jars */
+    private static final String XPATH_EXPRS = "//classpaths/path[@load='onUse']/load";
+
+    /** Cache the already loaded libraries */
+    private static Set<String> loadedModules = new HashSet<String>();
+
+    /**
+     * Load the module on the classpath
+     *
+     * The module have to be declared in the $SCI/etc/classpath.xml file.
+     *
+     * @param module the module to be loaded
+     */
+    public static void loadOnUse(String module) {
+        if (loadedModules.contains(module)) {
+            return;
+        }
+
+        // define XPath expression
+        String xpathExpression = XPATH_EXPRS + "[@on='" + module + "']";
+
+        // Initialize xpath
+        XPathFactory factory = XPathFactory.newInstance();
+        XPath xpath = factory.newXPath();
+
+        // initialize document factory
+        DocumentBuilderFactory domFactory = ScilabDocumentBuilderFactory.newInstance();
+        domFactory.setValidating(false);
+        domFactory.setNamespaceAware(true);
+
+        // Parse Classpath file
+        Document doc = null;
+        try {
+            DocumentBuilder builder = domFactory.newDocumentBuilder();
+            doc = builder.parse(new File(CLASSPATH_PATH));
+        } catch (ParserConfigurationException e) {
+            System.err.println("Error: " + e.getLocalizedMessage());
+            e.printStackTrace();
+            return;
+        } catch (SAXException e) {
+            System.err.println("Error: " + e.getLocalizedMessage());
+            e.printStackTrace();
+            return;
+        } catch (IOException e) {
+            System.err.println("Error: " + e.getLocalizedMessage());
+            e.printStackTrace();
+            return;
+        }
+
+        // Load JARs
+        try {
+            NodeList result = (NodeList) xpath.evaluate(xpathExpression, doc,
+                              XPathConstants.NODESET);
+
+            for (int i = 0; i < result.getLength(); i++) {
+                Node n = result.item(i).getParentNode();
+
+                String jar = n.getAttributes().getNamedItem("value").getNodeValue();
+                ClassPath.addFile(jar.replace("$SCILAB", SCI), 0);
+                loadedModules.add(module);
+            }
+
+        } catch (XPathExpressionException e) {
+            e.printStackTrace();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * This class is a static singleton
+     */
+    private LoadClassPath() { }
 }