diff java/jdc/examples/UnixMathExample.java @ 22:4ee8d6aa7721

- java binding cleanup, exposed free functions (not very oo, this entire binding) - java binding examples
author cslag
date Sat, 09 Apr 2016 18:18:34 -0500
parents 40a2c4198016
children
line wrap: on
line diff
--- a/java/jdc/examples/UnixMathExample.java	Wed Mar 30 23:40:52 2016 +0200
+++ b/java/jdc/examples/UnixMathExample.java	Sat Apr 09 18:18:34 2016 -0500
@@ -4,11 +4,11 @@
 {
    	public static void main(String args[])
    	{
-		long lib = DC.load("/usr/lib/libm.so");
+		long lib = DC.loadLibrary("/usr/lib/libm.so");
    		System.out.format("libm.so handle: %x\n", lib);
 
 		long f0 = DC.find(lib, "sqrtf");
-   		System.out.format("found sqrft at: %x\n", f0);
+   		System.out.format("found sqrtf at: %x\n", f0);
 
 		long f1 = DC.find(lib, "pow");
    		System.out.format("found pow at: %x\n", f1);
@@ -23,6 +23,10 @@
 		DC.argDouble(vm, 10.);
 		double r1 = DC.callDouble(vm, f1);
    		System.out.format("pow(2., 10.) = %f\n", r1);
+
+		// Done, cleanup.
+		DC.freeCallVM(vm);
+		DC.freeLibrary(lib);
 	}
 }