/usr/share/doc/libglpk-java/examples/java/OutOfMemory.java is in libglpk-java 1.11.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import org.gnu.glpk.GLPK;
import org.gnu.glpk.GLPKConstants;
import org.gnu.glpk.SWIGTYPE_p_double;
import org.gnu.glpk.SWIGTYPE_p_int;
/**
* This example file demonstrates that OutOfMemoryErrors are
* thrown if calloc fails.
*/
public class OutOfMemory {
/**
* This is the main function.
*/
public static void main(String[] args) {
SWIGTYPE_p_int ind;
System.out.println("Testing allocation of integer array.");
System.out.println("1: No error should occur");
ind = GLPK.new_intArray(3);
GLPK.delete_intArray(ind);
System.out.println("1: Success");
try {
System.out.println("2: Error should occur");
ind = GLPK.new_intArray(-1);
} catch (OutOfMemoryError ex) {
ex.printStackTrace(System.out);
System.out.println("2: Success");
System.exit(0);
}
System.out.println("2: Failure");
System.exit(1);
}
}
|