It's Sun proprietary code, but URLClassLoader isn't and it appears as
though you'd only need to override `findClass(String)' by iterating
over URLs given in `getURLs()' and then loading the classes with
JarInputStream. This inherits from FileInputStream which has the
close() method you'd call.
I confirmed the used beanshell class loader uses it, but this is under
OSX. I would be surprised if a Sun JVM under windows is different:
bsh %
java.net.URLClassLoader.class.isAssignableFrom(this.getClass().getClassLoader().getClass());
<true>
bsh % print(this.getClass().getClassLoader().getURLs());
java.net.URL []: {
file:/Users/<USERNAME>/opt/lib/java/bsh-2.0b4/lib/bsh-2.0b4.jar,
file:/Users/<USERNAME>/opt/lib/emacs/jde-2.3.5/java/bsh-commands/,
file:/Users/<USERNAME>/opt/lib/emacs/jde-2.3.5/java/lib/checkstyle-all.jar,
file:/Users/<USERNAME>/opt/lib/emacs/jde-2.3.5/java/lib/jakarta-regexp.jar,
file:/Users/<USERNAME>/opt/lib/emacs/jde-2.3.5/java/lib/jde.jar,
file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/classes.jar,
...
Matthew Wyatt writes:
> Paul,
> I couldn't find any JVM parameters that dealt with the behavior you
> described, and writing a class loader is way more effort than I'm willing to
> expend for this small annoyance. I took your advice to use the directory
> where the class files were, rather than the jar file, and that worked like a
> charm. Thanks,
> -Matt
> PS I guess I was thinking there would be some sort of exposed API (whether
> in bsh or jdee) that would allow you to, in effect, call close() on the
> stream attached to the file. Does anyone know of such a thing? (Feel free
> to point me to documentation.)
> PPS I don't believe I put that link in my first email; I think gmail thought
> that was an ip address, and linked automatically. Thanks for making me look
> like a prat, google!
>
> On Thu, Aug 28, 2008 at 5:33 PM, Paul Landes <[EMAIL PROTECTED]> wrote:
>
> > I don't have the answer, but I think I might be able to narrow it
> > down, which is the JVM. Look to see if there are some JVM parameters
> > you can pass so that once the classloader loads what it needs from the
> > jar, it closes the file.
> >
> > As you probably know, windows uses pessimistic locking so the kernel
> > doesn't let you do much with the file (depending on how it is opened).
> >
> > You might want to build classes in a directory structure instead and
> > use that directory as a classpath element. You might get better
> > results.
> >
> > You could of course write or extend a class loader and then put it in
> > the prebootclasspath, but I'd try building classes in a directory
> > first (i.e. javac -d <DIR_A> ..., then java -classpath DIR_A;path...)
> >
> >
> >
> > Matthew Wyatt writes:
> > > All,
> > > I've noticed that if I use JDEE to complete a method name, I can no
> > > longer delete the jar file that the BeanShell uses to look up the method
> > > names and signatures until I kill the process in the *JDEE bsh* buffer,
> > > because the BeanShell is holding onto the file handle. Is there a way
> > to
> > > force it to let go of the file after completing?
> > > I'm running on Win XP, SP 2, Emacs 22.2, JDE 2.3.5.1.
> > > If this is a known BeanShell issue, then I'm sorry to bring it up in
> > this
> > > mailing list. I couldn't find anything on this issue on google.
> > > Thanks for your time,
> > > -Matt
> > > <div dir="ltr">All,<br> I've noticed that if I use JDEE
> > to complete a method name, I can no longer delete the jar file that the
> > BeanShell uses to look up the method names and signatures until I kill the
> > process in the *JDEE bsh* buffer, because the BeanShell is holding onto the
> > file handle. Is there a way to force it to let go of the file after
> > completing?<br>
> > > I'm running on Win XP, SP 2, Emacs 22.2, JDE <a href="
> > http://2.3.5.1">2.3.5.1</a>.<br> If this is a known BeanShell
> > issue, then I'm sorry to bring it up in this mailing list. I
> > couldn't find anything on this issue on google.<br>
> > > Thanks for your time,<br>-Matt<br></div>
> > >
> > -------------------------------------------------------------------------
> > > This SF.Net email is sponsored by the Moblin Your Move Developer's
> > challenge
> > > Build the coolest Linux based applications with Moblin SDK & win great
> > prizes
> > > Grand prize is a trip for two to an Open Source event anywhere in the
> > world
> > >
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
> > > jdee-users mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/jdee-users
> >
> >
> > --
> > Paul Landes
> > [EMAIL PROTECTED]
> >
> <div dir="ltr">Paul,<br> I couldn't find any JVM parameters
> that dealt with the behavior you described, and writing a class loader is
> way more effort than I'm willing to expend for this small
> annoyance. I took your advice to use the directory where the class
> files were, rather than the jar file, and that worked like a charm.
> Thanks,<br>
> -Matt<br>PS I guess I was thinking there would be some sort of exposed API
> (whether in bsh or jdee) that would allow you to, in effect, call close() on
> the stream attached to the file. Does anyone know of such a
> thing? (Feel free to point me to documentation.)<br>
> PPS I don't believe I put that link in my first email; I think gmail
> thought that was an ip address, and linked automatically. Thanks for
> making me look like a prat, google!<br><br><div class="gmail_quote">On Thu,
> Aug 28, 2008 at 5:33 PM, Paul Landes <span dir="ltr"><<a
> href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>></span> wrote:<br>
> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204,
> 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I don't have the
> answer, but I think I might be able to narrow it<br>
> down, which is the JVM. Look to see if there are some JVM
> parameters<br>
> you can pass so that once the classloader loads what it needs from the<br>
> jar, it closes the file.<br>
> <br>
> As you probably know, windows uses pessimistic locking so the kernel<br>
> doesn't let you do much with the file (depending on how it is
> opened).<br>
> <br>
> You might want to build classes in a directory structure instead and<br>
> use that directory as a classpath element. You might get better<br>
> results.<br>
> <br>
> You could of course write or extend a class loader and then put it in<br>
> the prebootclasspath, but I'd try building classes in a directory<br>
> first (i.e. javac -d <DIR_A> ..., then java -classpath
> DIR_A;path...)<br>
> <div><div></div><div class="Wj3C7c"><br>
> <br>
> <br>
> Matthew Wyatt writes:<br>
> > All,<br>
> > I've noticed that if I use JDEE to complete a
> method name, I can no<br>
> > longer delete the jar file that the BeanShell uses to look up the
> method<br>
> > names and signatures until I kill the process in the *JDEE bsh*
> buffer,<br>
> > because the BeanShell is holding onto the file handle. Is
> there a way to<br>
> > force it to let go of the file after completing?<br>
> > I'm running on Win XP, SP 2, Emacs 22.2, JDE <a
> href="http://2.3.5.1" target="_blank">2.3.5.1</a>.<br>
> > If this is a known BeanShell issue, then I'm
> sorry to bring it up in this<br>
> > mailing list. I couldn't find anything on this issue on
> google.<br>
> > Thanks for your time,<br>
> > -Matt<br>
> </div></div> > <div
> dir="ltr">All,<br>&nbsp;&nbsp; I&#39;ve
> noticed that if I use JDEE to complete a method name, I can no longer delete
> the jar file that the BeanShell uses to look up the method names and
> signatures until I kill the process in the *JDEE bsh* buffer, because the
> BeanShell is holding onto the file handle.&nbsp; Is there a way to force
> it to let go of the file after completing?<br><br>
>
> > &nbsp;&nbsp; I&#39;m running on Win XP, SP 2, Emacs
> 22.2, JDE <a href="<a href="http://2.3.5.1"
> target="_blank">http://2.3.5.1</a>"><a href="http://2.3.5.1"
> target="_blank">2.3.5.1</a></a>.<br>&nbsp;&nbsp; If this
> is a known BeanShell issue, then I&#39;m sorry to bring it up in this
> mailing list.&nbsp; I couldn&#39;t find anything on this issue on
> google.<br><br>
>
> > &nbsp;&nbsp; Thanks for your
> time,<br>-Matt<br></div><br>
> >
> -------------------------------------------------------------------------<br>
> > This SF.Net email is sponsored by the Moblin Your Move
> Developer's challenge<br>
> > Build the coolest Linux based applications with Moblin SDK &
> win great prizes<br>
> > Grand prize is a trip for two to an Open Source event anywhere in
> the world<br>
> > <a
> href="http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________"
>
> target="_blank">http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________</a><br>
>
> > jdee-users mailing list<br>
> > <a
> href="mailto:[email protected]">[email protected]</a><br>
> > <a href="https://lists.sourceforge.net/lists/listinfo/jdee-users"
> target="_blank">https://lists.sourceforge.net/lists/listinfo/jdee-users</a><br>
> <font color="#888888"><br>
> <br>
> --<br>
> Paul Landes<br>
> <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a><br>
> </font></blockquote></div><br></div>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
> jdee-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jdee-users
--
Paul Landes
[EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
jdee-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jdee-users