Weijun Wang wrote:
But the current test passes without closing the stream, even on
Windows. I guess it's because the file opened is not in scratch
directory and needs not be cleaned up.
If we have to close the stream/channel, it seems the references need
to saved in DummyClassLoader's static fields and cleaned up in another
static method called in a finally clause of the test's main method.
The reason the original test failed in samevm is that
buffers[DIRECT_BUFFER].flip() is not called and its remaining() is
zero, and causes the error:
java.lang.ClassFormatError: Truncated class file
You are right, the file is the test.src directory and so isn't subject
to the clean-up. In that case I'm okay with the proposed changes. I do
think we should still close the FileChannel in readClassFile. Once a
file mapping is created then the FileChannel can be closed and this
would help avoid open file descriptors building up - this can happen
when running hunreds of tests in the same VM.
-Alan.