summaryrefslogtreecommitdiff
path: root/examples/api/java/Exceptions.java
diff options
context:
space:
mode:
Diffstat (limited to 'examples/api/java/Exceptions.java')
-rw-r--r--examples/api/java/Exceptions.java73
1 files changed, 37 insertions, 36 deletions
diff --git a/examples/api/java/Exceptions.java b/examples/api/java/Exceptions.java
index 2d62a7570..bc142571d 100644
--- a/examples/api/java/Exceptions.java
+++ b/examples/api/java/Exceptions.java
@@ -21,45 +21,46 @@ public class Exceptions
{
public static void main(String[] args)
{
- Solver solver = new Solver();
-
- solver.setOption("produce-models", "true");
-
- // Setting an invalid option
- try
- {
- solver.setOption("non-existing", "true");
- System.exit(1);
- }
- catch (Exception e)
+ try (Solver solver = new Solver())
{
- System.out.println(e.toString());
- }
+ solver.setOption("produce-models", "true");
- // Creating a term with an invalid type
- try
- {
- Sort integer = solver.getIntegerSort();
- Term x = solver.mkVar(integer, "x");
- Term invalidTerm = solver.mkTerm(Kind.AND, x, x);
- solver.checkSatAssuming(invalidTerm);
- System.exit(1);
- }
- catch (Exception e)
- {
- System.out.println(e.toString());
- }
+ // Setting an invalid option
+ try
+ {
+ solver.setOption("non-existing", "true");
+ System.exit(1);
+ }
+ catch (Exception e)
+ {
+ System.out.println(e.toString());
+ }
- // Asking for a model after unsat result
- try
- {
- solver.checkSatAssuming(solver.mkBoolean(false));
- solver.getModel(new Sort[] {}, new Term[] {});
- System.exit(1);
- }
- catch (Exception e)
- {
- System.out.println(e.toString());
+ // Creating a term with an invalid type
+ try
+ {
+ Sort integer = solver.getIntegerSort();
+ Term x = solver.mkVar(integer, "x");
+ Term invalidTerm = solver.mkTerm(Kind.AND, x, x);
+ solver.checkSatAssuming(invalidTerm);
+ System.exit(1);
+ }
+ catch (Exception e)
+ {
+ System.out.println(e.toString());
+ }
+
+ // Asking for a model after unsat result
+ try
+ {
+ solver.checkSatAssuming(solver.mkBoolean(false));
+ solver.getModel(new Sort[] {}, new Term[] {});
+ System.exit(1);
+ }
+ catch (Exception e)
+ {
+ System.out.println(e.toString());
+ }
}
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback