3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-13 04:28:17 +00:00

Java API: Added exception wrappers and build dependencies.

Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
Christoph M. Wintersteiger 2012-11-30 15:39:25 +00:00
parent 654c02701c
commit 0c1f2a8281
47 changed files with 4908 additions and 4554 deletions

View file

@ -159,7 +159,7 @@ class JavaExample
Sort t = f.Range(); Sort t = f.Range();
Sort[] dom = f.Domain(); Sort[] dom = f.Domain();
if (dom.length != 2 || !t.Equals(dom[0]) || !t.Equals(dom[1])) if (dom.length != 2 || !t.equals(dom[0]) || !t.equals(dom[1]))
{ {
System.out.println(Integer.toString(dom.length) + " " System.out.println(Integer.toString(dom.length) + " "
+ dom[0].toString() + " " + dom[1].toString() + " " + dom[0].toString() + " " + dom[1].toString() + " "
@ -700,7 +700,7 @@ class JavaExample
System.out.println(q2); System.out.println(q2);
} }
System.out.println(q1.Equals(q2)); System.out.println(q1.equals(q2));
} }
// / Prove that <tt>f(x, y) = f(w, v) implies y = v</tt> when // / Prove that <tt>f(x, y) = f(w, v) implies y = v</tt> when

View file

@ -990,10 +990,13 @@ class JavaDLLComponent(Component):
else: else:
out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) api/java/Native$(OBJ_EXT) libz3$(SO_EXT)\n') out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) api/java/Native$(OBJ_EXT) libz3$(SO_EXT)\n')
out.write('%s.jar: libz3java$(SO_EXT) ' % self.package_name) out.write('%s.jar: libz3java$(SO_EXT) ' % self.package_name)
# for java_file in get_java_files(self.src_dir): deps = ''
# out.write('%s ' % java_file) for jfile in get_java_files(self.src_dir):
# for java_file in get_java_files((self.src_dir + "/%s/enumerations") % subdir): deps += ('%s/%s ' % (self.to_src_dir, jfile))
# out.write('%s ' % java_file) for jfile in get_java_files((self.src_dir + "/enumerations")):
deps += ('%s/enumerations/%s ' % (self.to_src_dir, jfile))
if IS_WINDOWS: deps = deps.replace('/', '\\')
out.write(deps)
out.write('\n') out.write('\n')
t = ('\t%s %s/enumerations/*.java -d api/java/classes\n' % (JAVAC, self.to_src_dir)) t = ('\t%s %s/enumerations/*.java -d api/java/classes\n' % (JAVAC, self.to_src_dir))
if IS_WINDOWS: t = t.replace('/','\\') if IS_WINDOWS: t = t.replace('/','\\')
@ -1103,10 +1106,12 @@ class JavaExampleComponent(ExampleComponent):
if JAVA_ENABLED: if JAVA_ENABLED:
pkg = get_component(JAVA_COMPONENT).package_name + '.jar' pkg = get_component(JAVA_COMPONENT).package_name + '.jar'
out.write('_ex_%s: %s' % (self.name, pkg)) out.write('_ex_%s: %s' % (self.name, pkg))
# for javafile in get_java_files(self.ex_dir): deps = ''
# out.write(' ') for jfile in get_java_files(self.ex_dir):
# out.write('%s/%s' % (self.to_ex_dir, javafile)) out.write(' %s/%s' % (self.to_ex_dir, jfile))
out.write('\n') if IS_WINDOWS:
deps = deps.replace('/', '\\')
out.write('%s\n' % deps)
out.write('\t%s -cp %s ' % (JAVAC, pkg)) out.write('\t%s -cp %s ' % (JAVAC, pkg))
win_ex_dir = self.to_ex_dir win_ex_dir = self.to_ex_dir
for javafile in get_java_files(self.ex_dir): for javafile in get_java_files(self.ex_dir):

View file

@ -489,18 +489,19 @@ def mk_java():
java_native = open(java_nativef, 'w') java_native = open(java_nativef, 'w')
java_native.write('// Automatically generated file\n') java_native.write('// Automatically generated file\n')
java_native.write('package %s;\n' % get_component('java').package_name) java_native.write('package %s;\n' % get_component('java').package_name)
java_native.write('import %s.enumerations.*;\n' % get_component('java').package_name)
java_native.write('public final class Native {\n') java_native.write('public final class Native {\n')
java_native.write(' public static class IntPtr { public int value; }\n') java_native.write(' public static class IntPtr { public int value; }\n')
java_native.write(' public static class LongPtr { public long value; }\n') java_native.write(' public static class LongPtr { public long value; }\n')
java_native.write(' public static class StringPtr { public String value; }\n') java_native.write(' public static class StringPtr { public String value; }\n')
java_native.write(' public static class errorHandler { public long ptr; }\n') java_native.write(' public static class errorHandler { public long ptr; }\n')
if IS_WINDOWS: if IS_WINDOWS:
java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name) java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name)
else: else:
java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name[3:]) # We need 3: to extract the prexi 'lib' form the dll_name java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name[3:]) # We need 3: to extract the prexi 'lib' form the dll_name
java_native.write('\n\n')
for name, result, params in _dotnet_decls: for name, result, params in _dotnet_decls:
java_native.write(' public static native %s %s(' % (type2java(result), java_method_name(name))) java_native.write(' protected static native %s INTERNAL%s(' % (type2java(result), java_method_name(name)))
first = True first = True
i = 0; i = 0;
for param in params: for param in params:
@ -511,12 +512,46 @@ def mk_java():
java_native.write('%s a%d' % (param2java(param), i)) java_native.write('%s a%d' % (param2java(param), i))
i = i + 1 i = i + 1
java_native.write(');\n') java_native.write(');\n')
java_native.write(' public static void main(String[] args) {\n') java_native.write('\n\n')
java_native.write(' IntPtr major = new IntPtr(), minor = new IntPtr(), build = new IntPtr(), revision = new IntPtr();\n') # Exception wrappers
java_native.write(' getVersion(major, minor, build, revision);\n') for name, result, params in _dotnet_decls:
java_native.write(' System.out.format("Z3 (for Java) %d.%d.%d%n", major.value, minor.value, build.value);\n') java_native.write(' public static %s %s(' % (type2java(result), java_method_name(name)))
first = True
i = 0;
for param in params:
if first:
first = False
else:
java_native.write(', ')
java_native.write('%s a%d' % (param2java(param), i))
i = i + 1
java_native.write(')')
if len(params) > 0 and param_type(params[0]) == CONTEXT:
java_native.write(' throws Z3Exception')
java_native.write('\n')
java_native.write(' {\n')
java_native.write(' ')
if result != VOID:
java_native.write('%s res = ' % type2java(result))
java_native.write('INTERNAL%s(' % (java_method_name(name)))
first = True
i = 0;
for param in params:
if first:
first = False
else:
java_native.write(', ')
java_native.write('a%d' % i)
i = i + 1
java_native.write(');\n')
if len(params) > 0 and param_type(params[0]) == CONTEXT:
java_native.write(' Z3_error_code err = Z3_error_code.fromInt(INTERNALgetErrorCode(a0));\n')
java_native.write(' if (err != Z3_error_code.Z3_OK)\n')
java_native.write(' throw new Z3Exception(INTERNALgetErrorMsgEx(a0, err.toInt()));\n')
if result != VOID:
java_native.write(' return res;\n')
java_native.write(' }\n\n')
java_native.write('}\n') java_native.write('}\n')
java_native.write('}\n');
java_wrapper = open(java_wrapperf, 'w') java_wrapper = open(java_wrapperf, 'w')
java_wrapper.write('// Automatically generated file\n') java_wrapper.write('// Automatically generated file\n')
java_wrapper.write('#include<jni.h>\n') java_wrapper.write('#include<jni.h>\n')
@ -544,7 +579,7 @@ def mk_java():
java_wrapper.write(' delete [] NEW; \n\n') java_wrapper.write(' delete [] NEW; \n\n')
pkg_str = get_component('java').package_name.replace('.', '_') pkg_str = get_component('java').package_name.replace('.', '_')
for name, result, params in _dotnet_decls: for name, result, params in _dotnet_decls:
java_wrapper.write('JNIEXPORT %s JNICALL Java_%s_Native_%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name))) java_wrapper.write('JNIEXPORT %s JNICALL Java_%s_Native_INTERNAL%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name)))
i = 0; i = 0;
for param in params: for param in params:
java_wrapper.write(', ') java_wrapper.write(', ')

View file

@ -35,7 +35,7 @@ public class AST extends Z3Object
/** /**
* Object comparison. * Object comparison.
**/ **/
public boolean Equals(Object o) public boolean equals(Object o)
{ {
AST casted = (AST) o; AST casted = (AST) o;
if (casted == null) if (casted == null)
@ -49,7 +49,7 @@ public class AST extends Z3Object
* @return Negative if the object should be sorted before <paramref * @return Negative if the object should be sorted before <paramref
* name="other"/>, positive if after else zero. * name="other"/>, positive if after else zero.
**/ **/
public int CompareTo(Object other) throws Z3Exception public int compareTo(Object other) throws Z3Exception
{ {
if (other == null) if (other == null)
return 1; return 1;
@ -104,7 +104,7 @@ public class AST extends Z3Object
/** /**
* The kind of the AST. * The kind of the AST.
**/ **/
public Z3_ast_kind ASTKind() public Z3_ast_kind ASTKind() throws Z3Exception
{ {
return Z3_ast_kind.fromInt(Native.getAstKind(Context().nCtx(), return Z3_ast_kind.fromInt(Native.getAstKind(Context().nCtx(),
NativeObject())); NativeObject()));
@ -163,8 +163,14 @@ public class AST extends Z3Object
* A string representation of the AST. * A string representation of the AST.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.astToString(Context().nCtx(), NativeObject()); return Native.astToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
/** /**

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
public class ASTDecRefQueue extends IDecRefQueue public class ASTDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.incRef(ctx.nCtx(), obj); Native.incRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.decRef(ctx.nCtx(), obj); Native.decRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -18,7 +18,7 @@ class ASTMap extends Z3Object
* @return True if <paramref name="k"/> is a key in the map, false * @return True if <paramref name="k"/> is a key in the map, false
* otherwise. * otherwise.
**/ **/
public boolean Contains(AST k) public boolean Contains(AST k) throws Z3Exception
{ {
return Native.astMapContains(Context().nCtx(), NativeObject(), return Native.astMapContains(Context().nCtx(), NativeObject(),
@ -29,6 +29,7 @@ class ASTMap extends Z3Object
* Finds the value associated with the key <paramref name="k"/>. <remarks> * Finds the value associated with the key <paramref name="k"/>. <remarks>
* This function signs an error when <paramref name="k"/> is not a key in * This function signs an error when <paramref name="k"/> is not a key in
* the map. </remarks> <param name="k">An AST</param> * the map. </remarks> <param name="k">An AST</param>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public AST Find(AST k) throws Z3Exception public AST Find(AST k) throws Z3Exception
@ -41,7 +42,7 @@ class ASTMap extends Z3Object
* Stores or replaces a new key/value pair in the map. <param name="k">The * Stores or replaces a new key/value pair in the map. <param name="k">The
* key AST</param> <param name="v">The value AST</param> * key AST</param> <param name="v">The value AST</param>
**/ **/
public void Insert(AST k, AST v) public void Insert(AST k, AST v) throws Z3Exception
{ {
Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(), Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(),
@ -52,7 +53,7 @@ class ASTMap extends Z3Object
* Erases the key <paramref name="k"/> from the map. <param name="k">An * Erases the key <paramref name="k"/> from the map. <param name="k">An
* AST</param> * AST</param>
**/ **/
public void Erase(AST k) public void Erase(AST k) throws Z3Exception
{ {
Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject()); Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject());
@ -61,7 +62,7 @@ class ASTMap extends Z3Object
/** /**
* Removes all keys from the map. * Removes all keys from the map.
**/ **/
public void Reset() public void Reset() throws Z3Exception
{ {
Native.astMapReset(Context().nCtx(), NativeObject()); Native.astMapReset(Context().nCtx(), NativeObject());
} }
@ -69,13 +70,14 @@ class ASTMap extends Z3Object
/** /**
* The size of the map * The size of the map
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.astMapSize(Context().nCtx(), NativeObject()); return Native.astMapSize(Context().nCtx(), NativeObject());
} }
/** /**
* The keys stored in the map. * The keys stored in the map.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public ASTVector Keys() throws Z3Exception public ASTVector Keys() throws Z3Exception
@ -88,8 +90,14 @@ class ASTMap extends Z3Object
* Retrieves a string representation of the map. * Retrieves a string representation of the map.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.astMapToString(Context().nCtx(), NativeObject()); return Native.astMapToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
ASTMap(Context ctx, long obj) throws Z3Exception ASTMap(Context ctx, long obj) throws Z3Exception

View file

@ -14,7 +14,7 @@ class ASTVector extends Z3Object
/** /**
* The size of the vector * The size of the vector
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.astVectorSize(Context().nCtx(), NativeObject()); return Native.astVectorSize(Context().nCtx(), NativeObject());
} }
@ -33,7 +33,7 @@ class ASTVector extends Z3Object
NativeObject(), i)); NativeObject(), i));
} }
public void set(int i, AST value) public void set(int i, AST value) throws Z3Exception
{ {
Native.astVectorSet(Context().nCtx(), NativeObject(), i, Native.astVectorSet(Context().nCtx(), NativeObject(), i,
@ -44,7 +44,7 @@ class ASTVector extends Z3Object
* Resize the vector to <paramref name="newSize"/>. <param * Resize the vector to <paramref name="newSize"/>. <param
* name="newSize">The new size of the vector.</param> * name="newSize">The new size of the vector.</param>
**/ **/
public void Resize(int newSize) public void Resize(int newSize) throws Z3Exception
{ {
Native.astVectorResize(Context().nCtx(), NativeObject(), newSize); Native.astVectorResize(Context().nCtx(), NativeObject(), newSize);
} }
@ -53,9 +53,8 @@ class ASTVector extends Z3Object
* Add the AST <paramref name="a"/> to the back of the vector. The size is * Add the AST <paramref name="a"/> to the back of the vector. The size is
* increased by 1. <param name="a">An AST</param> * increased by 1. <param name="a">An AST</param>
**/ **/
public void Push(AST a) public void Push(AST a) throws Z3Exception
{ {
Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject()); Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject());
} }
@ -76,8 +75,14 @@ class ASTVector extends Z3Object
* Retrieves a string representation of the vector. * Retrieves a string representation of the vector.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.astVectorToString(Context().nCtx(), NativeObject()); return Native.astVectorToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
ASTVector(Context ctx, long obj) throws Z3Exception ASTVector(Context ctx, long obj) throws Z3Exception

View file

@ -15,7 +15,7 @@ public class ApplyResult extends Z3Object
/** /**
* The number of Subgoals. * The number of Subgoals.
**/ **/
public int NumSubgoals() public int NumSubgoals() throws Z3Exception
{ {
return Native.applyResultGetNumSubgoals(Context().nCtx(), return Native.applyResultGetNumSubgoals(Context().nCtx(),
NativeObject()); NativeObject());
@ -23,6 +23,7 @@ public class ApplyResult extends Z3Object
/** /**
* Retrieves the subgoals from the ApplyResult. * Retrieves the subgoals from the ApplyResult.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Goal[] Subgoals() throws Z3Exception public Goal[] Subgoals() throws Z3Exception
@ -52,8 +53,14 @@ public class ApplyResult extends Z3Object
* A string representation of the ApplyResult. * A string representation of the ApplyResult.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.applyResultToString(Context().nCtx(), NativeObject()); return Native.applyResultToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
ApplyResult(Context ctx, long obj) throws Z3Exception ApplyResult(Context ctx, long obj) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ApplyResultDecRefQueue extends IDecRefQueue class ApplyResultDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.applyResultIncRef(ctx.nCtx(), obj); Native.applyResultIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.applyResultDecRef(ctx.nCtx(), obj); Native.applyResultDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ASTMapDecRefQueue extends IDecRefQueue class ASTMapDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.astMapIncRef(ctx.nCtx(), obj); Native.astMapIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.astMapDecRef(ctx.nCtx(), obj); Native.astMapDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ASTVectorDecRefQueue extends IDecRefQueue class ASTVectorDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.astVectorIncRef(ctx.nCtx(), obj); Native.astVectorIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.astVectorDecRef(ctx.nCtx(), obj); Native.astVectorDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -51,8 +51,14 @@ public class BitVecNum extends BitVecExpr
* Returns a string representation of the numeral. * Returns a string representation of the numeral.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.getNumeralString(Context().nCtx(), NativeObject()); return Native.getNumeralString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
BitVecNum(Context ctx, long obj) throws Z3Exception BitVecNum(Context ctx, long obj) throws Z3Exception

View file

@ -13,7 +13,7 @@ public class BitVecSort extends Sort
/** /**
* The size of the bit-vector sort. * The size of the bit-vector sort.
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.getBvSortSize(Context().nCtx(), NativeObject()); return Native.getBvSortSize(Context().nCtx(), NativeObject());
} }

View file

@ -54,7 +54,7 @@ public class Constructor extends Z3Object
/** /**
* Destructor. * Destructor.
**/ **/
protected void finalize() protected void finalize() throws Z3Exception
{ {
Native.delConstructor(Context().nCtx(), NativeObject()); Native.delConstructor(Context().nCtx(), NativeObject());
} }

View file

@ -14,7 +14,7 @@ public class ConstructorList extends Z3Object
/** /**
* Destructor. * Destructor.
**/ **/
protected void finalize() protected void finalize() throws Z3Exception
{ {
Native.delConstructorList(Context().nCtx(), NativeObject()); Native.delConstructorList(Context().nCtx(), NativeObject());
} }

View file

@ -3088,7 +3088,13 @@ public class Context extends IDisposable
if (m_refCount == 0) if (m_refCount == 0)
{ {
m_n_err_handler = null; m_n_err_handler = null;
try
{
Native.delContext(m_ctx); Native.delContext(m_ctx);
} catch (Z3Exception e)
{
// OK.
}
m_ctx = 0; m_ctx = 0;
} else } else
/* re-queue the finalizer */ /* re-queue the finalizer */

View file

@ -14,7 +14,7 @@ public class DatatypeSort extends Sort
/** /**
* The number of constructors of the datatype sort. * The number of constructors of the datatype sort.
**/ **/
public int NumConstructors() public int NumConstructors() throws Z3Exception
{ {
return Native.getDatatypeSortNumConstructors(Context().nCtx(), return Native.getDatatypeSortNumConstructors(Context().nCtx(),
NativeObject()); NativeObject());

View file

@ -14,7 +14,7 @@ public class FiniteDomainSort extends Sort
/** /**
* The size of the finite domain sort. * The size of the finite domain sort.
**/ **/
public long Size() public long Size() throws Z3Exception
{ {
Native.LongPtr res = new Native.LongPtr(); Native.LongPtr res = new Native.LongPtr();
Native.getFiniteDomainSortSize(Context().nCtx(), NativeObject(), res); Native.getFiniteDomainSortSize(Context().nCtx(), NativeObject(), res);

View file

@ -17,9 +17,8 @@ public class Fixedpoint extends Z3Object
/** /**
* A string that describes all available fixedpoint solver parameters. * A string that describes all available fixedpoint solver parameters.
**/ **/
public String Help() public String Help() throws Z3Exception
{ {
return Native.fixedpointGetHelp(Context().nCtx(), NativeObject()); return Native.fixedpointGetHelp(Context().nCtx(), NativeObject());
} }
@ -38,6 +37,7 @@ public class Fixedpoint extends Z3Object
/** /**
* Retrieves parameter descriptions for Fixedpoint solver. * Retrieves parameter descriptions for Fixedpoint solver.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public ParamDescrs ParameterDescriptions() throws Z3Exception public ParamDescrs ParameterDescriptions() throws Z3Exception
@ -53,7 +53,6 @@ public class Fixedpoint extends Z3Object
**/ **/
public void Assert(BoolExpr[] constraints) throws Z3Exception public void Assert(BoolExpr[] constraints) throws Z3Exception
{ {
Context().CheckContextMatch(constraints); Context().CheckContextMatch(constraints);
for (BoolExpr a : constraints) for (BoolExpr a : constraints)
{ {
@ -156,7 +155,7 @@ public class Fixedpoint extends Z3Object
/** /**
* Creates a backtracking point. <seealso cref="Pop"/> * Creates a backtracking point. <seealso cref="Pop"/>
**/ **/
public void Push() public void Push() throws Z3Exception
{ {
Native.fixedpointPush(Context().nCtx(), NativeObject()); Native.fixedpointPush(Context().nCtx(), NativeObject());
} }
@ -166,7 +165,7 @@ public class Fixedpoint extends Z3Object
* thrown if Pop is called without a corresponding <code>Push</code> * thrown if Pop is called without a corresponding <code>Push</code>
* </remarks> <seealso cref="Push"/> * </remarks> <seealso cref="Push"/>
**/ **/
public void Pop() public void Pop() throws Z3Exception
{ {
Native.fixedpointPop(Context().nCtx(), NativeObject()); Native.fixedpointPop(Context().nCtx(), NativeObject());
} }
@ -199,7 +198,7 @@ public class Fixedpoint extends Z3Object
/** /**
* Retrieve explanation why fixedpoint engine returned status Unknown. * Retrieve explanation why fixedpoint engine returned status Unknown.
**/ **/
public String GetReasonUnknown() public String GetReasonUnknown() throws Z3Exception
{ {
return Native.fixedpointGetReasonUnknown(Context().nCtx(), return Native.fixedpointGetReasonUnknown(Context().nCtx(),
@ -209,7 +208,7 @@ public class Fixedpoint extends Z3Object
/** /**
* Retrieve the number of levels explored for a given predicate. * Retrieve the number of levels explored for a given predicate.
**/ **/
public int GetNumLevels(FuncDecl predicate) public int GetNumLevels(FuncDecl predicate) throws Z3Exception
{ {
return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(), return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(),
predicate.NativeObject()); predicate.NativeObject());
@ -232,6 +231,7 @@ public class Fixedpoint extends Z3Object
* at <tt>level</tt>. * at <tt>level</tt>.
**/ **/
public void AddCover(int level, FuncDecl predicate, Expr property) public void AddCover(int level, FuncDecl predicate, Expr property)
throws Z3Exception
{ {
Native.fixedpointAddCover(Context().nCtx(), NativeObject(), level, Native.fixedpointAddCover(Context().nCtx(), NativeObject(), level,
predicate.NativeObject(), property.NativeObject()); predicate.NativeObject(), property.NativeObject());
@ -242,15 +242,21 @@ public class Fixedpoint extends Z3Object
**/ **/
public String toString() public String toString()
{ {
return Native.fixedpointToString(Context().nCtx(), NativeObject(), 0, try
null); {
return Native.fixedpointToString(Context().nCtx(), NativeObject(),
0, null);
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
/** /**
* Instrument the Datalog engine on which table representation to use for * Instrument the Datalog engine on which table representation to use for
* recursive predicate. * recursive predicate.
**/ **/
public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds) public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds) throws Z3Exception
{ {
Native.fixedpointSetPredicateRepresentation(Context().nCtx(), Native.fixedpointSetPredicateRepresentation(Context().nCtx(),
@ -262,7 +268,7 @@ public class Fixedpoint extends Z3Object
/** /**
* Convert benchmark given as set of axioms, rules and queries to a string. * Convert benchmark given as set of axioms, rules and queries to a string.
**/ **/
public String toString(BoolExpr[] queries) public String toString(BoolExpr[] queries) throws Z3Exception
{ {
return Native.fixedpointToString(Context().nCtx(), NativeObject(), return Native.fixedpointToString(Context().nCtx(), NativeObject(),

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class FixedpointDecRefQueue extends IDecRefQueue class FixedpointDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.fixedpointIncRef(ctx.nCtx(), obj); Native.fixedpointIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.fixedpointDecRef(ctx.nCtx(), obj); Native.fixedpointDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -52,8 +52,14 @@ public class FuncDecl extends AST
* A string representations of the function declaration. * A string representations of the function declaration.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.funcDeclToString(Context().nCtx(), NativeObject()); return Native.funcDeclToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
/** /**
@ -76,7 +82,7 @@ public class FuncDecl extends AST
* The size of the domain of the function declaration <seealso * The size of the domain of the function declaration <seealso
* cref="Arity"/> * cref="Arity"/>
**/ **/
public int DomainSize() public int DomainSize() throws Z3Exception
{ {
return Native.getDomainSize(Context().nCtx(), NativeObject()); return Native.getDomainSize(Context().nCtx(), NativeObject());
} }
@ -356,16 +362,16 @@ public class FuncDecl extends AST
} }
/** /**
* Create expression that applies function to arguments. * Create expression that applies function to arguments. <param
* <param name="args"></param> * name="args"></param>
* *
* @return * @return
**/ **/
/* operator this[] not translated */ /* operator this[] not translated */
/** /**
* Create expression that applies function to arguments. * Create expression that applies function to arguments. <param
* <param name="args"></param> * name="args"></param>
* *
* @return * @return
**/ **/
@ -376,8 +382,8 @@ public class FuncDecl extends AST
} }
/** /**
* Create expression that applies function to one argument. * Create expression that applies function to one argument. <param
* <param name="arg"></param> * name="arg"></param>
* *
* @return * @return
**/ **/

View file

@ -33,7 +33,7 @@ public class FuncInterp extends Z3Object
/** /**
* The number of arguments of the entry. * The number of arguments of the entry.
**/ **/
public int NumArgs() public int NumArgs() throws Z3Exception
{ {
return Native.funcEntryGetNumArgs(Context().nCtx(), NativeObject()); return Native.funcEntryGetNumArgs(Context().nCtx(), NativeObject());
} }
@ -93,7 +93,7 @@ public class FuncInterp extends Z3Object
/** /**
* The number of entries in the function interpretation. * The number of entries in the function interpretation.
**/ **/
public int NumEntries() public int NumEntries() throws Z3Exception
{ {
return Native.funcInterpGetNumEntries(Context().nCtx(), NativeObject()); return Native.funcInterpGetNumEntries(Context().nCtx(), NativeObject());
} }
@ -127,7 +127,7 @@ public class FuncInterp extends Z3Object
/** /**
* The arity of the function interpretation * The arity of the function interpretation
**/ **/
public int Arity() public int Arity() throws Z3Exception
{ {
return Native.funcInterpGetArity(Context().nCtx(), NativeObject()); return Native.funcInterpGetArity(Context().nCtx(), NativeObject());
} }

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class FuncInterpDecRefQueue extends IDecRefQueue class FuncInterpDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.funcInterpIncRef(ctx.nCtx(), obj); Native.funcInterpIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.funcInterpDecRef(ctx.nCtx(), obj); Native.funcInterpDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class FuncInterpEntryDecRefQueue extends IDecRefQueue class FuncInterpEntryDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.funcEntryIncRef(ctx.nCtx(), obj); Native.funcEntryIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.funcEntryDecRef(ctx.nCtx(), obj); Native.funcEntryDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -21,7 +21,7 @@ public class Goal extends Z3Object
* applied when the objective is to find a proof for a given goal. * applied when the objective is to find a proof for a given goal.
* </remarks> * </remarks>
**/ **/
public Z3_goal_prec Precision() public Z3_goal_prec Precision() throws Z3Exception
{ {
return Z3_goal_prec.fromInt(Native.goalPrecision(Context().nCtx(), return Z3_goal_prec.fromInt(Native.goalPrecision(Context().nCtx(),
NativeObject())); NativeObject()));
@ -30,7 +30,7 @@ public class Goal extends Z3Object
/** /**
* Indicates whether the goal is precise. * Indicates whether the goal is precise.
**/ **/
public boolean IsPrecise() public boolean IsPrecise() throws Z3Exception
{ {
return Precision() == Z3_goal_prec.Z3_GOAL_PRECISE; return Precision() == Z3_goal_prec.Z3_GOAL_PRECISE;
} }
@ -38,7 +38,7 @@ public class Goal extends Z3Object
/** /**
* Indicates whether the goal is an under-approximation. * Indicates whether the goal is an under-approximation.
**/ **/
public boolean IsUnderApproximation() public boolean IsUnderApproximation() throws Z3Exception
{ {
return Precision() == Z3_goal_prec.Z3_GOAL_UNDER; return Precision() == Z3_goal_prec.Z3_GOAL_UNDER;
} }
@ -46,7 +46,7 @@ public class Goal extends Z3Object
/** /**
* Indicates whether the goal is an over-approximation. * Indicates whether the goal is an over-approximation.
**/ **/
public boolean IsOverApproximation() public boolean IsOverApproximation() throws Z3Exception
{ {
return Precision() == Z3_goal_prec.Z3_GOAL_OVER; return Precision() == Z3_goal_prec.Z3_GOAL_OVER;
} }
@ -55,13 +55,14 @@ public class Goal extends Z3Object
* Indicates whether the goal is garbage (i.e., the product of over- and * Indicates whether the goal is garbage (i.e., the product of over- and
* under-approximations). * under-approximations).
**/ **/
public boolean IsGarbage() public boolean IsGarbage() throws Z3Exception
{ {
return Precision() == Z3_goal_prec.Z3_GOAL_UNDER_OVER; return Precision() == Z3_goal_prec.Z3_GOAL_UNDER_OVER;
} }
/** /**
* Adds the <paramref name="constraints"/> to the given goal. * Adds the <paramref name="constraints"/> to the given goal.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public void Assert(BoolExpr[] constraints) throws Z3Exception public void Assert(BoolExpr[] constraints) throws Z3Exception
@ -76,6 +77,7 @@ public class Goal extends Z3Object
/** /**
* Adds a <paramref name="constraint"/> to the given goal. * Adds a <paramref name="constraint"/> to the given goal.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public void Assert(BoolExpr constraint) throws Z3Exception public void Assert(BoolExpr constraint) throws Z3Exception
@ -88,7 +90,7 @@ public class Goal extends Z3Object
/** /**
* Indicates whether the goal contains `false'. * Indicates whether the goal contains `false'.
**/ **/
public boolean Inconsistent() public boolean Inconsistent() throws Z3Exception
{ {
return Native.goalInconsistent(Context().nCtx(), NativeObject()); return Native.goalInconsistent(Context().nCtx(), NativeObject());
} }
@ -97,7 +99,7 @@ public class Goal extends Z3Object
* The depth of the goal. <remarks> This tracks how many transformations * The depth of the goal. <remarks> This tracks how many transformations
* were applied to it. </remarks> * were applied to it. </remarks>
**/ **/
public int Depth() public int Depth() throws Z3Exception
{ {
return Native.goalDepth(Context().nCtx(), NativeObject()); return Native.goalDepth(Context().nCtx(), NativeObject());
} }
@ -105,7 +107,7 @@ public class Goal extends Z3Object
/** /**
* Erases all formulas from the given goal. * Erases all formulas from the given goal.
**/ **/
public void Reset() public void Reset() throws Z3Exception
{ {
Native.goalReset(Context().nCtx(), NativeObject()); Native.goalReset(Context().nCtx(), NativeObject());
} }
@ -113,13 +115,14 @@ public class Goal extends Z3Object
/** /**
* The number of formulas in the goal. * The number of formulas in the goal.
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.goalSize(Context().nCtx(), NativeObject()); return Native.goalSize(Context().nCtx(), NativeObject());
} }
/** /**
* The formulas in the goal. * The formulas in the goal.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public BoolExpr[] Formulas() throws Z3Exception public BoolExpr[] Formulas() throws Z3Exception
@ -135,7 +138,7 @@ public class Goal extends Z3Object
/** /**
* The number of formulas, subformulas and terms in the goal. * The number of formulas, subformulas and terms in the goal.
**/ **/
public int NumExprs() public int NumExprs() throws Z3Exception
{ {
return Native.goalNumExprs(Context().nCtx(), NativeObject()); return Native.goalNumExprs(Context().nCtx(), NativeObject());
} }
@ -144,7 +147,7 @@ public class Goal extends Z3Object
* Indicates whether the goal is empty, and it is precise or the product of * Indicates whether the goal is empty, and it is precise or the product of
* an under approximation. * an under approximation.
**/ **/
public boolean IsDecidedSat() public boolean IsDecidedSat() throws Z3Exception
{ {
return Native.goalIsDecidedSat(Context().nCtx(), NativeObject()); return Native.goalIsDecidedSat(Context().nCtx(), NativeObject());
} }
@ -153,7 +156,7 @@ public class Goal extends Z3Object
* Indicates whether the goal contains `false', and it is precise or the * Indicates whether the goal contains `false', and it is precise or the
* product of an over approximation. * product of an over approximation.
**/ **/
public boolean IsDecidedUnsat() public boolean IsDecidedUnsat() throws Z3Exception
{ {
return Native.goalIsDecidedUnsat(Context().nCtx(), NativeObject()); return Native.goalIsDecidedUnsat(Context().nCtx(), NativeObject());
} }
@ -161,6 +164,7 @@ public class Goal extends Z3Object
/** /**
* Translates (copies) the Goal to the target Context <paramref * Translates (copies) the Goal to the target Context <paramref
* name="ctx"/>. * name="ctx"/>.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Goal Translate(Context ctx) throws Z3Exception public Goal Translate(Context ctx) throws Z3Exception
@ -190,8 +194,14 @@ public class Goal extends Z3Object
* @return A string representation of the Goal. * @return A string representation of the Goal.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.goalToString(Context().nCtx(), NativeObject()); return Native.goalToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
Goal(Context ctx, long obj) throws Z3Exception Goal(Context ctx, long obj) throws Z3Exception
@ -199,7 +209,8 @@ public class Goal extends Z3Object
super(ctx, obj); super(ctx, obj);
} }
Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs) throws Z3Exception Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs)
throws Z3Exception
{ {
super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false, super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false,
(unsatCores) ? true : false, (proofs) ? true : false)); (unsatCores) ? true : false, (proofs) ? true : false));

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class GoalDecRefQueue extends IDecRefQueue class GoalDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.goalIncRef(ctx.nCtx(), obj); Native.goalIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.goalDecRef(ctx.nCtx(), obj); Native.goalDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -53,7 +53,13 @@ public class IntNum extends IntExpr
* Returns a string representation of the numeral. * Returns a string representation of the numeral.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.getNumeralString(Context().nCtx(), NativeObject()); return Native.getNumeralString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
} }

View file

@ -105,13 +105,14 @@ public class Model extends Z3Object
/** /**
* The number of constants that have an interpretation in the model. * The number of constants that have an interpretation in the model.
**/ **/
public int NumConsts() public int NumConsts() throws Z3Exception
{ {
return Native.modelGetNumConsts(Context().nCtx(), NativeObject()); return Native.modelGetNumConsts(Context().nCtx(), NativeObject());
} }
/** /**
* The function declarations of the constants in the model. * The function declarations of the constants in the model.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public FuncDecl[] ConstDecls() throws Z3Exception public FuncDecl[] ConstDecls() throws Z3Exception
@ -127,13 +128,14 @@ public class Model extends Z3Object
/** /**
* The number of function interpretations in the model. * The number of function interpretations in the model.
**/ **/
public int NumFuncs() public int NumFuncs() throws Z3Exception
{ {
return Native.modelGetNumFuncs(Context().nCtx(), NativeObject()); return Native.modelGetNumFuncs(Context().nCtx(), NativeObject());
} }
/** /**
* The function declarations of the function interpretations in the model. * The function declarations of the function interpretations in the model.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public FuncDecl[] FuncDecls() throws Z3Exception public FuncDecl[] FuncDecls() throws Z3Exception
@ -148,6 +150,7 @@ public class Model extends Z3Object
/** /**
* All symbols that have an interpretation in the model. * All symbols that have an interpretation in the model.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public FuncDecl[] Decls() throws Z3Exception public FuncDecl[] Decls() throws Z3Exception
@ -206,6 +209,7 @@ public class Model extends Z3Object
/** /**
* Alias for <code>Eval</code>. * Alias for <code>Eval</code>.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Expr Evaluate(Expr t, boolean completion) throws Z3Exception public Expr Evaluate(Expr t, boolean completion) throws Z3Exception
@ -217,7 +221,7 @@ public class Model extends Z3Object
* The number of uninterpreted sorts that the model has an interpretation * The number of uninterpreted sorts that the model has an interpretation
* for. * for.
**/ **/
public int NumSorts() public int NumSorts() throws Z3Exception
{ {
return Native.modelGetNumSorts(Context().nCtx(), NativeObject()); return Native.modelGetNumSorts(Context().nCtx(), NativeObject());
} }
@ -228,6 +232,7 @@ public class Model extends Z3Object
* in a formula. The interpretation for a sort is a finite set of distinct * in a formula. The interpretation for a sort is a finite set of distinct
* values. We say this finite set is the "universe" of the sort. </remarks> * values. We say this finite set is the "universe" of the sort. </remarks>
* <seealso cref="NumSorts"/> <seealso cref="SortUniverse"/> * <seealso cref="NumSorts"/> <seealso cref="SortUniverse"/>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Sort[] Sorts() throws Z3Exception public Sort[] Sorts() throws Z3Exception
@ -268,8 +273,14 @@ public class Model extends Z3Object
* @return A string representation of the model. * @return A string representation of the model.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.modelToString(Context().nCtx(), NativeObject()); return Native.modelToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
Model(Context ctx, long obj) throws Z3Exception Model(Context ctx, long obj) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ModelDecRefQueue extends IDecRefQueue class ModelDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.modelIncRef(ctx.nCtx(), obj); Native.modelIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.modelDecRef(ctx.nCtx(), obj); Native.modelDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -16,7 +16,7 @@ public class ParamDescrs extends Z3Object
/** /**
* validate a set of parameters. * validate a set of parameters.
**/ **/
public void Validate(Params p) public void Validate(Params p) throws Z3Exception
{ {
Native.paramsValidate(Context().nCtx(), p.NativeObject(), Native.paramsValidate(Context().nCtx(), p.NativeObject(),
@ -26,7 +26,7 @@ public class ParamDescrs extends Z3Object
/** /**
* Retrieve kind of parameter. * Retrieve kind of parameter.
**/ **/
public Z3_param_kind GetKind(Symbol name) public Z3_param_kind GetKind(Symbol name) throws Z3Exception
{ {
return Z3_param_kind.fromInt(Native.paramDescrsGetKind( return Z3_param_kind.fromInt(Native.paramDescrsGetKind(
@ -53,7 +53,7 @@ public class ParamDescrs extends Z3Object
/** /**
* The size of the ParamDescrs. * The size of the ParamDescrs.
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.paramDescrsSize(Context().nCtx(), NativeObject()); return Native.paramDescrsSize(Context().nCtx(), NativeObject());
} }
@ -62,8 +62,14 @@ public class ParamDescrs extends Z3Object
* Retrieves a string representation of the ParamDescrs. * Retrieves a string representation of the ParamDescrs.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.paramDescrsToString(Context().nCtx(), NativeObject()); return Native.paramDescrsToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
ParamDescrs(Context ctx, long obj) throws Z3Exception ParamDescrs(Context ctx, long obj) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ParamDescrsDecRefQueue extends IDecRefQueue class ParamDescrsDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.paramDescrsIncRef(ctx.nCtx(), obj); Native.paramDescrsIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.paramDescrsDecRef(ctx.nCtx(), obj); Native.paramDescrsDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -79,8 +79,14 @@ public class Params extends Z3Object
* A string representation of the parameter set. * A string representation of the parameter set.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.paramsToString(Context().nCtx(), NativeObject()); return Native.paramsToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
Params(Context ctx) throws Z3Exception Params(Context ctx) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ParamsDecRefQueue extends IDecRefQueue class ParamsDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.paramsIncRef(ctx.nCtx(), obj); Native.paramsIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.paramsDecRef(ctx.nCtx(), obj); Native.paramsDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -15,7 +15,7 @@ public class Pattern extends AST
/** /**
* The number of terms in the pattern. * The number of terms in the pattern.
**/ **/
public int NumTerms() public int NumTerms() throws Z3Exception
{ {
return Native.getPatternNumTerms(Context().nCtx(), NativeObject()); return Native.getPatternNumTerms(Context().nCtx(), NativeObject());
} }
@ -40,8 +40,14 @@ public class Pattern extends AST
* A string representation of the pattern. * A string representation of the pattern.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.patternToString(Context().nCtx(), NativeObject()); return Native.patternToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
Pattern(Context ctx, long obj) throws Z3Exception Pattern(Context ctx, long obj) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ProbeDecRefQueue extends IDecRefQueue class ProbeDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.probeIncRef(ctx.nCtx(), obj); Native.probeIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.probeDecRef(ctx.nCtx(), obj); Native.probeDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -16,7 +16,7 @@ public class Quantifier extends BoolExpr
/** /**
* Indicates whether the quantifier is universal. * Indicates whether the quantifier is universal.
**/ **/
public boolean IsUniversal() public boolean IsUniversal() throws Z3Exception
{ {
return Native.isQuantifierForall(Context().nCtx(), NativeObject()); return Native.isQuantifierForall(Context().nCtx(), NativeObject());
} }
@ -24,7 +24,7 @@ public class Quantifier extends BoolExpr
/** /**
* Indicates whether the quantifier is existential. * Indicates whether the quantifier is existential.
**/ **/
public boolean IsExistential() public boolean IsExistential() throws Z3Exception
{ {
return !IsUniversal(); return !IsUniversal();
} }
@ -32,7 +32,7 @@ public class Quantifier extends BoolExpr
/** /**
* The weight of the quantifier. * The weight of the quantifier.
**/ **/
public int Weight() public int Weight() throws Z3Exception
{ {
return Native.getQuantifierWeight(Context().nCtx(), NativeObject()); return Native.getQuantifierWeight(Context().nCtx(), NativeObject());
} }
@ -40,7 +40,7 @@ public class Quantifier extends BoolExpr
/** /**
* The number of patterns. * The number of patterns.
**/ **/
public int NumPatterns() public int NumPatterns() throws Z3Exception
{ {
return Native return Native
.getQuantifierNumPatterns(Context().nCtx(), NativeObject()); .getQuantifierNumPatterns(Context().nCtx(), NativeObject());
@ -64,7 +64,7 @@ public class Quantifier extends BoolExpr
/** /**
* The number of no-patterns. * The number of no-patterns.
**/ **/
public int NumNoPatterns() public int NumNoPatterns() throws Z3Exception
{ {
return Native.getQuantifierNumNoPatterns(Context().nCtx(), return Native.getQuantifierNumNoPatterns(Context().nCtx(),
NativeObject()); NativeObject());
@ -88,7 +88,7 @@ public class Quantifier extends BoolExpr
/** /**
* The number of bound variables. * The number of bound variables.
**/ **/
public int NumBound() public int NumBound() throws Z3Exception
{ {
return Native.getQuantifierNumBound(Context().nCtx(), NativeObject()); return Native.getQuantifierNumBound(Context().nCtx(), NativeObject());
} }

View file

@ -7,6 +7,7 @@
package com.microsoft.z3; package com.microsoft.z3;
import java.math.BigInteger; import java.math.BigInteger;
/** /**
* Rational Numerals * Rational Numerals
**/ **/
@ -62,8 +63,14 @@ public class RatNum extends RealExpr
* Returns a string representation of the numeral. * Returns a string representation of the numeral.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.getNumeralString(Context().nCtx(), NativeObject()); return Native.getNumeralString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
RatNum(Context ctx, long obj) throws Z3Exception RatNum(Context ctx, long obj) throws Z3Exception

View file

@ -14,7 +14,7 @@ public class RelationSort extends Sort
/** /**
* The arity of the relation sort. * The arity of the relation sort.
**/ **/
public int Arity() public int Arity() throws Z3Exception
{ {
return Native.getRelationArity(Context().nCtx(), NativeObject()); return Native.getRelationArity(Context().nCtx(), NativeObject());
} }

View file

@ -16,13 +16,14 @@ public class Solver extends Z3Object
/** /**
* A string that describes all available solver parameters. * A string that describes all available solver parameters.
**/ **/
public String Help() public String Help() throws Z3Exception
{ {
return Native.solverGetHelp(Context().nCtx(), NativeObject()); return Native.solverGetHelp(Context().nCtx(), NativeObject());
} }
/** /**
* Sets the solver parameters. * Sets the solver parameters.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public void setParameters(Params value) throws Z3Exception public void setParameters(Params value) throws Z3Exception
@ -34,6 +35,7 @@ public class Solver extends Z3Object
/** /**
* Retrieves parameter descriptions for solver. * Retrieves parameter descriptions for solver.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public ParamDescrs ParameterDescriptions() throws Z3Exception public ParamDescrs ParameterDescriptions() throws Z3Exception
@ -46,7 +48,7 @@ public class Solver extends Z3Object
* The current number of backtracking points (scopes). <seealso cref="Pop"/> * The current number of backtracking points (scopes). <seealso cref="Pop"/>
* <seealso cref="Push"/> * <seealso cref="Push"/>
**/ **/
public int NumScopes() public int NumScopes() throws Z3Exception
{ {
return Native.solverGetNumScopes(Context().nCtx(), NativeObject()); return Native.solverGetNumScopes(Context().nCtx(), NativeObject());
} }
@ -54,7 +56,7 @@ public class Solver extends Z3Object
/** /**
* Creates a backtracking point. <seealso cref="Pop"/> * Creates a backtracking point. <seealso cref="Pop"/>
**/ **/
public void Push() public void Push() throws Z3Exception
{ {
Native.solverPush(Context().nCtx(), NativeObject()); Native.solverPush(Context().nCtx(), NativeObject());
} }
@ -62,7 +64,7 @@ public class Solver extends Z3Object
/** /**
* Backtracks one backtracking point. <remarks>. * Backtracks one backtracking point. <remarks>.
**/ **/
public void Pop() public void Pop() throws Z3Exception
{ {
Pop(1); Pop(1);
} }
@ -72,7 +74,7 @@ public class Solver extends Z3Object
* an exception is thrown if <paramref name="n"/> is not smaller than * an exception is thrown if <paramref name="n"/> is not smaller than
* <code>NumScopes</code></remarks> <seealso cref="Push"/> * <code>NumScopes</code></remarks> <seealso cref="Push"/>
**/ **/
public void Pop(int n) public void Pop(int n) throws Z3Exception
{ {
Native.solverPop(Context().nCtx(), NativeObject(), n); Native.solverPop(Context().nCtx(), NativeObject(), n);
} }
@ -81,13 +83,14 @@ public class Solver extends Z3Object
* Resets the Solver. <remarks>This removes all assertions from the * Resets the Solver. <remarks>This removes all assertions from the
* solver.</remarks> * solver.</remarks>
**/ **/
public void Reset() public void Reset() throws Z3Exception
{ {
Native.solverReset(Context().nCtx(), NativeObject()); Native.solverReset(Context().nCtx(), NativeObject());
} }
/** /**
* Assert a multiple constraints into the solver. * Assert a multiple constraints into the solver.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public void Assert(BoolExpr[] constraints) throws Z3Exception public void Assert(BoolExpr[] constraints) throws Z3Exception
@ -102,16 +105,19 @@ public class Solver extends Z3Object
/** /**
* Assert one constraint into the solver. * Assert one constraint into the solver.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public void Assert(BoolExpr constraint) throws Z3Exception public void Assert(BoolExpr constraint) throws Z3Exception
{ {
Context().CheckContextMatch(constraint); Context().CheckContextMatch(constraint);
Native.solverAssert(Context().nCtx(), NativeObject(), constraint.NativeObject()); Native.solverAssert(Context().nCtx(), NativeObject(),
constraint.NativeObject());
} }
/** /**
* The number of assertions in the solver. * The number of assertions in the solver.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public int NumAssertions() throws Z3Exception public int NumAssertions() throws Z3Exception
@ -123,6 +129,7 @@ public class Solver extends Z3Object
/** /**
* The set of asserted formulas. * The set of asserted formulas.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public BoolExpr[] Assertions() throws Z3Exception public BoolExpr[] Assertions() throws Z3Exception
@ -141,7 +148,7 @@ public class Solver extends Z3Object
* <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso * <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso
* cref="Proof"/> </remarks> * cref="Proof"/> </remarks>
**/ **/
public Status Check(Expr[] assumptions) public Status Check(Expr[] assumptions) throws Z3Exception
{ {
Z3_lbool r; Z3_lbool r;
if (assumptions == null) if (assumptions == null)
@ -167,7 +174,7 @@ public class Solver extends Z3Object
* <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso * <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso
* cref="Proof"/> </remarks> * cref="Proof"/> </remarks>
**/ **/
public Status Check() public Status Check() throws Z3Exception
{ {
return Check(null); return Check(null);
} }
@ -177,6 +184,7 @@ public class Solver extends Z3Object
* <code>null</code> if <code>Check</code> was not invoked before, if its * <code>null</code> if <code>Check</code> was not invoked before, if its
* results was not <code>SATISFIABLE</code>, or if model production is not * results was not <code>SATISFIABLE</code>, or if model production is not
* enabled. </remarks> * enabled. </remarks>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Model Model() throws Z3Exception public Model Model() throws Z3Exception
@ -193,6 +201,7 @@ public class Solver extends Z3Object
* <code>null</code> if <code>Check</code> was not invoked before, if its * <code>null</code> if <code>Check</code> was not invoked before, if its
* results was not <code>UNSATISFIABLE</code>, or if proof production is * results was not <code>UNSATISFIABLE</code>, or if proof production is
* disabled. </remarks> * disabled. </remarks>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Expr Proof() throws Z3Exception public Expr Proof() throws Z3Exception
@ -209,6 +218,7 @@ public class Solver extends Z3Object
* is a subset of <code>Assertions</code> The result is empty if * is a subset of <code>Assertions</code> The result is empty if
* <code>Check</code> was not invoked before, if its results was not * <code>Check</code> was not invoked before, if its results was not
* <code>UNSATISFIABLE</code>, or if core production is disabled. </remarks> * <code>UNSATISFIABLE</code>, or if core production is disabled. </remarks>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Expr[] UnsatCore() throws Z3Exception public Expr[] UnsatCore() throws Z3Exception
@ -227,14 +237,14 @@ public class Solver extends Z3Object
* A brief justification of why the last call to <code>Check</code> returned * A brief justification of why the last call to <code>Check</code> returned
* <code>UNKNOWN</code>. * <code>UNKNOWN</code>.
**/ **/
public String ReasonUnknown() public String ReasonUnknown() throws Z3Exception
{ {
return Native.solverGetReasonUnknown(Context().nCtx(), NativeObject()); return Native.solverGetReasonUnknown(Context().nCtx(), NativeObject());
} }
/** /**
* Solver statistics. * Solver statistics.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Statistics Statistics() throws Z3Exception public Statistics Statistics() throws Z3Exception
@ -247,8 +257,14 @@ public class Solver extends Z3Object
* A string representation of the solver. * A string representation of the solver.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.solverToString(Context().nCtx(), NativeObject()); return Native.solverToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
Solver(Context ctx, long obj) throws Z3Exception Solver(Context ctx, long obj) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class SolverDecRefQueue extends IDecRefQueue class SolverDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.solverIncRef(ctx.nCtx(), obj); Native.solverIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.solverDecRef(ctx.nCtx(), obj); Native.solverDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -37,7 +37,7 @@ public class Sort extends AST
* *
* @return * @return
**/ **/
public boolean Equals(Object o) public boolean equals(Object o)
{ {
Sort casted = (Sort) o; Sort casted = (Sort) o;
if (casted == null) if (casted == null)
@ -85,8 +85,14 @@ public class Sort extends AST
* A string representation of the sort. * A string representation of the sort.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.sortToString(Context().nCtx(), NativeObject()); return Native.sortToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
/** /**

View file

@ -56,6 +56,7 @@ public class Statistics extends Z3Object
/** /**
* The string representation of the the entry's value. * The string representation of the the entry's value.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public String Value() throws Z3Exception public String Value() throws Z3Exception
@ -106,20 +107,27 @@ public class Statistics extends Z3Object
* A string representation of the statistical data. * A string representation of the statistical data.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.statsToString(Context().nCtx(), NativeObject()); return Native.statsToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
/** /**
* The number of statistical data. * The number of statistical data.
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.statsSize(Context().nCtx(), NativeObject()); return Native.statsSize(Context().nCtx(), NativeObject());
} }
/** /**
* The data entries. * The data entries.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Entry[] Entries() throws Z3Exception public Entry[] Entries() throws Z3Exception
@ -147,7 +155,7 @@ public class Statistics extends Z3Object
/** /**
* The statistical counters. * The statistical counters.
**/ **/
public String[] Keys() public String[] Keys() throws Z3Exception
{ {
int n = Size(); int n = Size();
String[] res = new String[n]; String[] res = new String[n];
@ -159,6 +167,7 @@ public class Statistics extends Z3Object
/** /**
* The value of a particular statistical counter. <remarks>Returns null if * The value of a particular statistical counter. <remarks>Returns null if
* the key is unknown.</remarks> * the key is unknown.</remarks>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Entry get(String key) throws Z3Exception public Entry get(String key) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class StatisticsDecRefQueue extends IDecRefQueue class StatisticsDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.statsIncRef(ctx.nCtx(), obj); Native.statsIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.statsDecRef(ctx.nCtx(), obj); Native.statsDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -16,7 +16,7 @@ public class Symbol extends Z3Object
/** /**
* The kind of the symbol (int or string) * The kind of the symbol (int or string)
**/ **/
protected Z3_symbol_kind Kind() protected Z3_symbol_kind Kind() throws Z3Exception
{ {
return Z3_symbol_kind.fromInt(Native.getSymbolKind(Context().nCtx(), return Z3_symbol_kind.fromInt(Native.getSymbolKind(Context().nCtx(),
NativeObject())); NativeObject()));
@ -25,7 +25,7 @@ public class Symbol extends Z3Object
/** /**
* Indicates whether the symbol is of Int kind * Indicates whether the symbol is of Int kind
**/ **/
public boolean IsIntSymbol() public boolean IsIntSymbol() throws Z3Exception
{ {
return Kind() == Z3_symbol_kind.Z3_INT_SYMBOL; return Kind() == Z3_symbol_kind.Z3_INT_SYMBOL;
} }
@ -33,7 +33,7 @@ public class Symbol extends Z3Object
/** /**
* Indicates whether the symbol is of string kind. * Indicates whether the symbol is of string kind.
**/ **/
public boolean IsStringSymbol() public boolean IsStringSymbol() throws Z3Exception
{ {
return Kind() == Z3_symbol_kind.Z3_STRING_SYMBOL; return Kind() == Z3_symbol_kind.Z3_STRING_SYMBOL;
} }

View file

@ -18,7 +18,7 @@ public class Tactic extends Z3Object
/** /**
* A string containing a description of parameters accepted by the tactic. * A string containing a description of parameters accepted by the tactic.
**/ **/
public String Help() public String Help() throws Z3Exception
{ {
return Native.tacticGetHelp(Context().nCtx(), NativeObject()); return Native.tacticGetHelp(Context().nCtx(), NativeObject());
} }

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class TacticDecRefQueue extends IDecRefQueue class TacticDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.tacticIncRef(ctx.nCtx(), obj); Native.tacticIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.tacticDecRef(ctx.nCtx(), obj); Native.tacticDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -25,7 +25,7 @@ public class TupleSort extends Sort
/** /**
* The number of fields in the tuple. * The number of fields in the tuple.
**/ **/
public int NumFields() public int NumFields() throws Z3Exception
{ {
return Native.getTupleSortNumFields(Context().nCtx(), NativeObject()); return Native.getTupleSortNumFields(Context().nCtx(), NativeObject());
} }