jakarta-bcel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alan" <nob...@eircom.net>
Subject Is Classpath holding onto file-handles?
Date Sat, 06 Dec 2003 00:52:51 GMT
My code begins thusly;

org.apache.bcel.util.ClassPath classPath = new org.apache.bcel.util.ClassPath(aPathToSomeJar);
org.apache.bcel.Repository.setRepository(org.apache.bcel.util.SyntheticRepository.getInstance(classPath));

I then load files from the repository, modify them, send them to a new jar file, and when
all the modifications are complete, delete the original jar file, and rename the new one to
that of the original. Or at least thats the plan.

I struggled all day to try figure out why java.io.File.delete returned false, indicating that
it could not delete the original file, as per my plan. It seemed likely that a handle to the
file in question was still in existance, but I couldnt figure out where it was ... until I
looked in org.apache.bcel.util.ClassPath. Upon doing so I saw this line

vec.addElement(new Zip(new ZipFile(file)));

(file takes the value of each archive in the supplied classpath string). My guess is that,
before I can delete the file, I have to invoke the ZipFile.close method for the ZipFile that
was attached to it. My trouble is that BCEL code does not do this.

This is, I think, mostly a request for functionality in future versions, although if anyone
can tell me if Im on the right or wrong track, or suggest an elegant work-around Id appreciate
it. Should future revisions not include some sort of dispose() method in org.apache.bcel.util.ClassPath
or org.apache.bcel.Repository that enables the user to close the files opened by BCEL?

Thanks (and apologies if Im wrong),

Al.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message