diff options
Diffstat (limited to 'src/runtime/java/org')
| -rw-r--r-- | src/runtime/java/org/grammaticalframework/PGF.java | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/runtime/java/org/grammaticalframework/PGF.java b/src/runtime/java/org/grammaticalframework/PGF.java index 777edbd98..6ff0a21a4 100644 --- a/src/runtime/java/org/grammaticalframework/PGF.java +++ b/src/runtime/java/org/grammaticalframework/PGF.java @@ -1,25 +1,31 @@ package org.grammaticalframework; public class PGF { - static native PGF readPGF(String path); + public static native PGF readPGF(String path); + + public void close() { + if (pool != 0) { + free(pool); + pool = 0; + gr = 0; + } + } - private int pool; - private int gr; + private static native void free(long pool); + + private long pool; + private long gr; - private PGF(int pool, int gr) { + private PGF(long pool, long gr) { this.pool = pool; this.gr = gr; } + protected void finalize () throws Throwable { + close(); + } + static { System.loadLibrary("jpgf"); } - - public void test() { - System.out.println("pool="+pool+", gr="+gr); - } - - public static void main(String[] args) { - readPGF("/home/krasimir/www.grammaticalframework.org/treebanks/PennTreebank/ParseEngAbs.pgf").test(); - } } |
