3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 21:38:44 +00:00

Bugfix for object finalization in Java API.

Relates to #205 and #245
This commit is contained in:
Christoph M. Wintersteiger 2015-10-14 12:43:09 +01:00
parent 6263252bf5
commit e312b47be6
4 changed files with 40 additions and 14 deletions

View file

@ -41,13 +41,12 @@ public class AST extends Z3Object implements Comparable
return false; return false;
} }
return return (this == casted) ||
(this == casted) ||
(this != null) && (this != null) &&
(casted != null) && (casted != null) &&
(getContext().nCtx() == casted.getContext().nCtx()) && (getContext().nCtx() == casted.getContext().nCtx()) &&
(Native.isEqAst(getContext().nCtx(), getNativeObject(), casted.getNativeObject())); (Native.isEqAst(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
} }
/** /**
* Object Comparison. * Object Comparison.

View file

@ -80,12 +80,21 @@ public class Constructor extends Z3Object
/** /**
* Destructor. * Destructor.
* @throws Throwable
* @throws Z3Exception on error * @throws Z3Exception on error
**/ **/
protected void finalize() protected void finalize() throws Throwable
{ {
try {
Native.delConstructor(getContext().nCtx(), getNativeObject()); Native.delConstructor(getContext().nCtx(), getNativeObject());
} }
catch (Throwable t) {
throw t;
}
finally {
super.finalize();
}
}
private int n = 0; private int n = 0;

View file

@ -24,12 +24,21 @@ public class ConstructorList extends Z3Object
{ {
/** /**
* Destructor. * Destructor.
* @throws Throwable
* @throws Z3Exception on error * @throws Z3Exception on error
**/ **/
protected void finalize() protected void finalize() throws Throwable
{ {
try {
Native.delConstructorList(getContext().nCtx(), getNativeObject()); Native.delConstructorList(getContext().nCtx(), getNativeObject());
} }
catch (Throwable t) {
throw t;
}
finally {
super.finalize();
}
}
ConstructorList(Context ctx, long obj) ConstructorList(Context ctx, long obj)
{ {

View file

@ -25,11 +25,20 @@ public class Z3Object extends IDisposable
{ {
/** /**
* Finalizer. * Finalizer.
* @throws Throwable
**/ **/
protected void finalize() protected void finalize() throws Throwable
{ {
try {
dispose(); dispose();
} }
catch (Throwable t) {
throw t;
}
finally {
super.finalize();
}
}
/** /**
* Disposes of the underlying native Z3 object. * Disposes of the underlying native Z3 object.