ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen McConnell" <mcconn...@dpml.net>
Subject RE: Jar Locking
Date Thu, 31 Aug 2006 17:19:52 GMT
 

> -----Original Message-----
> From: Marc Farrow [mailto:marc.farrow@gmail.com] 
> Sent: Friday, 1 September 2006 2:35 AM
> To: Ant Users List
> Subject: Re: Jar Locking
> 
> Thanks Stephen.  If I set all references to Ant to null and 
> forced GC, would that resolve the problem?

Well, umm, this is tricky.  If your loading a task or data type definition I
think Ant holds a strong reference to the class which would suggest that
setting things to null would not change (because strong references are held
for the life of the JVM).  I may be wrong here because it's been a while
since I dug into Ant internals on task class references - but one of the Ant
Developers could probably confirm things.  

However, if your running Ant as an embedded solution - then in principal the
disposal of the Ant project would clear any task and datatype references and
you may have a chance.  But this is tricky stuff and getting it right really
requires that the Ant project and all Ant related stuff is loaded in a child
classloader relative to the launching application (i.e. it's the classloader
disposal that is key to the releasing of the file reference).  

It is possible - but it's not trivial.

Cheers, Steve.



> 
> On 8/31/06, Stephen McConnell <mcconnell@dpml.net> wrote:
> >
> >
> >
> > > -----Original Message-----
> > > From: Marc Farrow [mailto:marc.farrow@gmail.com]
> > > Sent: Thursday, 31 August 2006 6:13 AM
> > > To: ant-user
> > > Subject: Jar Locking
> > >
> > > Everytime I run an ant task (either in NetBeans or from 
> within Java 
> > > Code), the executing jar gets locked and I cannot delete 
> the jar.  I 
> > > am copying the ant script and the dependent jar that it 
> needs to run 
> > > and then executing the ant tasks.  Then I wish to delete 
> the "new" 
> > > copy I just created to run, but a jar I am using is 
> locked and will 
> > > not allow me.
> > >  This in on a Windows 2000 machine.
> >
> > The jar file is locked because it is referenced in a 
> classloader.  The 
> > lock will be released once the classloader is garbage collected but 
> > that will not happen until all references to all classes defined by 
> > the jar are no longer referenced.  If the jar file in question is 
> > referenced by Ant then chances are that your file will not 
> be released 
> > until the Ant Project instance is no longer in use.
> >
> > The solution to the problem is to handle the creation and updating 
> > operations under two distinct projects.  One project handles the 
> > creation of a new jar file, and the second project handles the 
> > replication of the jar (with the assumption that your 
> second project 
> > does not include a classpath reference to the jar file).
> >
> > Cheers, Steve.
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
> additional 
> > commands, e-mail: user-help@ant.apache.org
> >
> >
> 
> 
> --
> Marc Farrow
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message