// Get the info file within that folder.
ProgramResourceLocator.File compileModuleInfoFileLocator = moduleFolder.extendFile(module.getName() + "." + Module.COMPILED_MODULE_SUFFIX);
// Put the module info into a byte array.
NakedByteArrayOutputStream bos = new NakedByteArrayOutputStream(8192);
RecordOutputStream ros = new RecordOutputStream(bos);
Exception exception = null;
try {
module.write(ros);
} catch (IOException saveException) {
exception = saveException;
} finally {
try {
ros.close();
} catch (IOException ioe) {
exception = ioe;
}
}
if (exception != null) {
logger.logMessage(new CompilerMessage(new MessageKind.Warning.DebugMessage("Failed saving compiled module info for " + module.getName()), exception));
}
// Create an input stream on the byte array, and use this to set the file contents.
InputStream is = new ByteArrayInputStream(bos.getByteArray(), 0, bos.getCount());
try {
resourceRepository.setContents(compileModuleInfoFileLocator, is);
} catch (IOException e) {
logger.logMessage(new CompilerMessage(new MessageKind.Warning.DebugMessage("Failed saving compiled module info for " + module.getName()), e));
}