|
10 | 10 | import java.lang.reflect.Method; |
11 | 11 | import java.net.URISyntaxException; |
12 | 12 | import java.net.URL; |
13 | | -import java.net.URLEncoder; |
14 | 13 | import java.security.CodeSource; |
15 | 14 | import java.security.ProtectionDomain; |
16 | 15 |
|
@@ -204,22 +203,27 @@ static String getSupportCodeLocation() throws MatlabConnectionException { |
204 | 203 | if (url != null) { |
205 | 204 | //Convert from url to absolute path |
206 | 205 | try { |
207 | | - // make sure that the url is properly encoded |
208 | | - URL encoded = new URL(URLEncoder.encode(url.toString(), "UTF-8")); |
209 | | - File file = new File(encoded.toURI()).getCanonicalFile(); |
| 206 | + // generate canonical file using URL path |
| 207 | + File file = new File(url.getPath()).getCanonicalFile(); |
210 | 208 | if (file.exists()) { |
211 | 209 | return file.getAbsolutePath(); |
212 | 210 | } else { |
213 | | - ClassLoader loader = Configuration.class.getClassLoader(); |
214 | | - throw new MatlabConnectionException("Support code location was determined improperly." + |
215 | | - " Location does not exist.\n" + |
216 | | - "Location determined as: " + file.getAbsolutePath() + "\n" + |
217 | | - "File: " + file + "\n" + |
218 | | - "URL Location: " + url + "\n" + |
219 | | - "Code Source: " + codeSource + "\n" + |
220 | | - "Protection Domain: " + domain + "\n" + |
221 | | - "Class Loader: " + loader + |
222 | | - (loader == null ? "" : "\nClass Loader Class: " + loader.getClass())); |
| 211 | + // generate canonical file using URI |
| 212 | + file = new File(url.toURI()).getCanonicalFile(); |
| 213 | + if (file.exists()) { |
| 214 | + return file.getAbsolutePath(); |
| 215 | + } else { |
| 216 | + ClassLoader loader = Configuration.class.getClassLoader(); |
| 217 | + throw new MatlabConnectionException("Support code location was determined improperly." + |
| 218 | + " Location does not exist.\n" + |
| 219 | + "Location determined as: " + file.getAbsolutePath() + "\n" + |
| 220 | + "File: " + file + "\n" + |
| 221 | + "URL Location: " + url + "\n" + |
| 222 | + "Code Source: " + codeSource + "\n" + |
| 223 | + "Protection Domain: " + domain + "\n" + |
| 224 | + "Class Loader: " + loader + |
| 225 | + (loader == null ? "" : "\nClass Loader Class: " + loader.getClass())); |
| 226 | + } |
223 | 227 | } |
224 | 228 | } |
225 | 229 | //Unable to resolve canconical path |
|
0 commit comments