Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 115044 Details for
Bug 190279
[server] [plan] Problems cleaning up when undeploying Servletbrdige WAR
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
URLClassLoader closer
URLClassLoaderCloser.java (text/plain), 2.32 KB, created by
Thomas Watson
on 2008-10-14 11:01:58 EDT
(
hide
)
Description:
URLClassLoader closer
Filename:
MIME Type:
Creator:
Thomas Watson
Created:
2008-10-14 11:01:58 EDT
Size:
2.32 KB
patch
obsolete
>package test.jared; > >import java.lang.reflect.Field; >import java.lang.reflect.Method; >import java.net.URL; >import java.net.URLClassLoader; >import java.util.Iterator; >import java.util.Map; >import java.util.zip.ZipFile; > >public class URLClassLoaderCloser { > > public static void closeLoader(URLClassLoader cl) { > URL[] urls = cl.getURLs(); > Field ucpField; > try { > ucpField = URLClassLoader.class.getDeclaredField("ucp"); > ucpField.setAccessible(true); > } catch (NoSuchFieldException e) { > // fail silently > return; > } > ucpField.setAccessible(true); > Object ucp; > try { > ucp = ucpField.get(cl); > } catch (IllegalAccessException e) { > // fail silently > return; > } > Method getLoader; > try { > getLoader = ucp.getClass().getDeclaredMethod("getLoader", new Class[] {URL.class}); > } catch (NoSuchMethodException e) { > // fail silently > return; > } > getLoader.setAccessible(true); > Field jarField = null; > Field lmapField = null; > for (int i = 0; i < urls.length; i++) { > Object loader; > try { > loader = getLoader.invoke(ucp, new Object[] {urls[i]}); > } catch (Exception e) { > // continue to next loader > continue; > } > if (jarField == null) { > try { > jarField = loader.getClass().getDeclaredField("jar"); > jarField.setAccessible(true); > } catch (Exception e) { > //continue to next loader > continue; > } > } > if (jarField != null) { > ZipFile zipFile; > try { > zipFile = (ZipFile) jarField.get(loader); > zipFile.close(); > } catch (Exception e) { > // continue to lmap field > } > } > if (lmapField == null) { > try { > lmapField = loader.getClass().getDeclaredField("lmap"); > lmapField.setAccessible(true); > } catch (Exception e) { > continue; > } > } > if (lmapField != null) { > try { > Map lmap = (Map) lmapField.get(loader); > for (Iterator iLoaders = lmap.values().iterator(); iLoaders.hasNext();) { > Object innerLoader = iLoaders.next(); > if (jarField != null) { > try { > ZipFile zipFile = (ZipFile) jarField.get(innerLoader); > zipFile.close(); > } catch (Exception e) { > //continue to next loader in lmap > continue; > } > } > } > } catch (Exception e) { > continue; > } > } > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 190279
:
69566
| 115044 |
115535
|
115574
|
115926