import jagi.*;
import java.util.*;
import java.util.regex.*;
+import java.util.logging.*;
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.io.*;
import java.net.*;
public class Compiler {
+ private static final Logger log = Logger.getLogger("jagi-fs");
private final Map<Path, File> files = new HashMap<>();
private final Map<Path, ClassLoader> libs = new HashMap<>();
private final Collection<Path> searchpath = new ArrayList<>();
}
private Path findlib(String nm) {
+ try {
+ Path p = Paths.get(nm);
+ if(Files.isRegularFile(p))
+ return(p);
+ } catch(InvalidPathException e) {
+ }
for(Path dir : searchpath) {
Path jar = dir.resolve(nm + ".jar");
if(Files.isRegularFile(jar))
synchronized(this) {
FileTime mtime = Files.getLastModifiedTime(name);
if((this.mtime == null) || (this.mtime.compareTo(mtime) < 0)) {
- mod = new Module(name);
+ Module pmod = this.mod;
+ this.mod = new Module(name);
this.mtime = mtime;
+ if(pmod instanceof AutoCloseable) {
+ try {
+ ((AutoCloseable)pmod).close();
+ } catch(Exception e) {
+ log.log(Level.WARNING, String.format("Error when disposing updated module %s", pmod.file), e);
+ }
+ }
}
}
}