mirror of
https://github.com/Z3Prover/z3
synced 2025-11-25 23:19:32 +00:00
Improved Java phantom references (#7131)
* Reworked phantom reference handling. - Replaced IDecRefQueue with a new Z3ReferenceQueue class - Z3ReferenceQueue manages custom subclasses of phantom references in a doubly-linked list - Replaced all subclasses of IDecRefQueue with subclasses of Z3ReferenceQueue.Reference. These custom reference classes are embedded in the class they reference count. - Context now owns a single Z3ReferenceQueue for all types of references. * Made Statistics.Entry a static subclass * Made Context.close idempotent (as recommended) * Update CMakeLists.txt for building the Java API. * Updated CMakeLists.txt again. * Use correct SuppressWarning annotation to silence the compiler * Formatting
This commit is contained in:
parent
f7691d34fd
commit
a3d00ce356
41 changed files with 448 additions and 805 deletions
|
|
@ -18,6 +18,8 @@ Author:
|
|||
package com.microsoft.z3;
|
||||
|
||||
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
|
||||
public class Simplifier extends Z3Object {
|
||||
/*
|
||||
* A string containing a description of parameters accepted by the simplifier.
|
||||
|
|
@ -32,7 +34,7 @@ public class Simplifier extends Z3Object {
|
|||
* Retrieves parameter descriptions for Simplifiers.
|
||||
*/
|
||||
public ParamDescrs getParameterDescriptions() {
|
||||
return new ParamDescrs(getContext(), Native.simplifierGetParamDescrs(getContext().nCtx(), getNativeObject()));
|
||||
return new ParamDescrs(getContext(), Native.simplifierGetParamDescrs(getContext().nCtx(), getNativeObject()));
|
||||
}
|
||||
|
||||
Simplifier(Context ctx, long obj)
|
||||
|
|
@ -53,6 +55,18 @@ public class Simplifier extends Z3Object {
|
|||
|
||||
@Override
|
||||
void addToReferenceQueue() {
|
||||
getContext().getSimplifierDRQ().storeReference(getContext(), this);
|
||||
getContext().getReferenceQueue().storeReference(this, SimplifierRef::new);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SimplifierRef extends Z3ReferenceQueue.Reference<Simplifier> {
|
||||
|
||||
private SimplifierRef(Simplifier referent, ReferenceQueue<Z3Object> q) {
|
||||
super(referent, q);
|
||||
}
|
||||
|
||||
@Override
|
||||
void decRef(Context ctx, long z3Obj) {
|
||||
Native.simplifierDecRef(ctx.nCtx(), z3Obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue