@Override public Method run() { try { final URLClassLoader loader = getSystemLoader(); final Object cp = getURLClassPath(loader); final Class<?> clazz = cp.getClass(); try { return clazz.getDeclaredMethod("getURLs", URL.class); } catch (final NoSuchMethodException e) { return clazz.getDeclaredMethod("getURLs"); } } catch (final Exception e) { throw new LoaderRuntimeException(e); } }
@Override public Method run() { try { final URLClassLoader loader = getSystemLoader(); final Object cp = getURLClassPath(loader); final Class<?> clazz = cp.getClass(); try { return clazz.getDeclaredMethod("getURLs", URL.class); } catch (final NoSuchMethodException e) { return clazz.getDeclaredMethod("getURLs"); } } catch (final Exception e) { throw new LoaderRuntimeException(e); } }
private void rebuildJavaClassPathVariable() throws Exception { final URLClassLoader loader = getSystemLoader(); final Object cp = getURLClassPath(loader); final Method getURLsMethod = getGetURLsMethod(); final URL[] urls = (URL[]) getURLsMethod.invoke(cp); if (urls.length < 1) { return; } final StringBuilder path = new StringBuilder(urls.length * 32); File s = new File(URLDecoder.decode(urls[0].getFile(), "UTF-8")); path.append(s.getPath()); for (int i = 1; i < urls.length; i++) { path.append(File.pathSeparator); s = new File(URLDecoder.decode(urls[i].getFile(), "UTF-8")); path.append(s.getPath()); } try { System.setProperty("java.class.path", path.toString()); } catch (final Exception e) { // no-op } }
private void rebuildJavaClassPathVariable() throws Exception { sun.misc.URLClassPath cp = getURLClassPath(getSystemLoader()); URL[] urls = cp.getURLs(); if (urls.length < 1) return; StringBuffer path = new StringBuffer(urls.length * 32); File s = new File(URLDecoder.decode(urls[0].getFile())); path.append(s.getPath()); for (int i = 1; i < urls.length; i++) { path.append(File.pathSeparator); s = new File(URLDecoder.decode(urls[i].getFile())); path.append(s.getPath()); } try { System.setProperty("java.class.path", path.toString()); } catch (Exception e) { } } }
private void rebuildJavaClassPathVariable() throws Exception { final URLClassLoader loader = getSystemLoader(); final Object cp = getURLClassPath(loader); final Method getURLsMethod = getGetURLsMethod(); final URL[] urls = (URL[]) getURLsMethod.invoke(cp); if (urls.length < 1) { return; } final StringBuilder path = new StringBuilder(urls.length * 32); File s = new File(URLDecoder.decode(urls[0].getFile(), "UTF-8")); path.append(s.getPath()); for (int i = 1; i < urls.length; i++) { path.append(File.pathSeparator); s = new File(URLDecoder.decode(urls[i].getFile(), "UTF-8")); path.append(s.getPath()); } try { System.setProperty("java.class.path", path.toString()); } catch (final Exception e) { // no-op } }