X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fjagi%2Ffs%2FCompiler.java;h=b277e003274b42d08b415ff52222d30d54c61199;hb=54de0442296cdb195759d1f3ed56f77f77348bf0;hp=e7a66a19a1e43c7530f74aae7c534102c32a94fe;hpb=2be6677a7e36d486834ae804d5db08aaea7e32a6;p=jagi.git diff --git a/src/jagi/fs/Compiler.java b/src/jagi/fs/Compiler.java index e7a66a1..b277e00 100644 --- a/src/jagi/fs/Compiler.java +++ b/src/jagi/fs/Compiler.java @@ -3,12 +3,14 @@ package jagi.fs; 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 files = new HashMap<>(); private final Map libs = new HashMap<>(); private final Collection searchpath = new ArrayList<>(); @@ -235,6 +237,12 @@ public class Compiler { } 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)) @@ -317,8 +325,16 @@ public class Compiler { 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); + } + } } } }