@SuppressWarnings("unchecked")
private static synchronized void initializeCaches(Environment environment, boolean force) throws IOException {
if (environment.getCacheDir() == null)
return;
Path stdlibVersion = environment.createCachePath("version");
if (!stdlibVersion.getFile().exists() || !FileCommands.readFileAsString(stdlibVersion).equals(StdLib.VERSION)) {
for (File f : environment.getCacheDir().getFile().listFiles())
f.delete();
FileCommands.writeToFile(stdlibVersion, StdLib.VERSION);
}
Path sdfCachePath = environment.createCachePath("sdfCaches");
Path strCachePath = environment.createCachePath("strCaches");
if (sdfCaches == null || force)
sdfCaches = new HashMap<Path, Map<String,ModuleKeyCache<Path>>>();
if (strCaches == null || force)
strCaches = new HashMap<Path, Map<String, ModuleKeyCache<Path>>>();
ObjectInputStream sdfIn = null;
ObjectInputStream strIn = null;
try{
sdfIn = new ObjectInputStream(new FileInputStream(sdfCachePath.getFile()));
if (!sdfCaches.containsKey(environment.getCacheDir())) {
Map<String, ModuleKeyCache<Path>> sdfLocalCaches = (Map<String, ModuleKeyCache<Path>>) sdfIn.readObject();
sdfCaches.put(environment.getCacheDir(), sdfLocalCaches);
}
strIn = new ObjectInputStream(new FileInputStream(strCachePath.getFile()));
if (!strCaches.containsKey(environment.getCacheDir())) {
Map<String, ModuleKeyCache<Path>> strLocalCaches = (Map<String, ModuleKeyCache<Path>>) strIn.readObject();
strCaches.put(environment.getCacheDir(), strLocalCaches);
}
} catch (Exception e) {