Mercurial Hosting > luan
comparison src/luan/LuanState.java @ 1222:cb422386f6b5
logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 25 Mar 2018 17:35:30 -0600 |
parents | d3a3ca116e42 |
children | d41997776788 |
comparison
equal
deleted
inserted
replaced
1221:b99947af8b79 | 1222:cb422386f6b5 |
---|---|
6 import java.lang.ref.WeakReference; | 6 import java.lang.ref.WeakReference; |
7 import java.util.List; | 7 import java.util.List; |
8 import java.util.ArrayList; | 8 import java.util.ArrayList; |
9 import java.util.Map; | 9 import java.util.Map; |
10 import java.util.HashMap; | 10 import java.util.HashMap; |
11 import org.slf4j.Logger; | |
12 import org.slf4j.LoggerFactory; | |
11 import luan.impl.LuanCompiler; | 13 import luan.impl.LuanCompiler; |
12 import luan.modules.BasicLuan; | 14 import luan.modules.BasicLuan; |
13 import luan.modules.JavaLuan; | 15 import luan.modules.JavaLuan; |
14 | 16 |
15 | 17 |
16 public final class LuanState implements LuanCloneable { | 18 public final class LuanState implements LuanCloneable { |
19 private static final Logger logger = LoggerFactory.getLogger(LuanState.class); | |
20 | |
17 public LuanJavaOk javaOk; | 21 public LuanJavaOk javaOk; |
18 private Map registry; | 22 private Map registry; |
19 private final List<Reference<Closeable>> onClose = new ArrayList<Reference<Closeable>>(); | 23 private final List<Reference<Closeable>> onClose = new ArrayList<Reference<Closeable>>(); |
20 public boolean isLocked = false; | 24 public boolean isLocked = false; |
21 | 25 |
44 | 48 |
45 public void onClose(Closeable c) { | 49 public void onClose(Closeable c) { |
46 onClose.add(new WeakReference<Closeable>(c)); | 50 onClose.add(new WeakReference<Closeable>(c)); |
47 } | 51 } |
48 | 52 |
49 public void close() throws IOException { | 53 public void close() { |
50 for( Reference<Closeable> ref : onClose ) { | 54 for( Reference<Closeable> ref : onClose ) { |
51 Closeable c = ref.get(); | 55 Closeable c = ref.get(); |
52 if( c != null ) | 56 if( c != null ) { |
53 c.close(); | 57 try { |
58 c.close(); | |
59 } catch(IOException e) { | |
60 logger.error(c.toString(),e); | |
61 } | |
62 } | |
54 } | 63 } |
55 onClose.clear(); | 64 onClose.clear(); |
56 } | 65 } |
57 | 66 |
58 protected void finalize() throws Throwable { | 67 protected void finalize() throws Throwable { |