Browse Source

JNI-160: add Message.getInstanceCount()

JNI-160
heck 4 years ago
parent
commit
42fad14bb9
  1. 9
      src/codegen/gen_java_Message.ysl2

9
src/codegen/gen_java_Message.ysl2

@ -37,12 +37,14 @@ tstylesheet {
public class «$cname» implements MessageInterface, AutoCloseable, Serializable { public class «$cname» implements MessageInterface, AutoCloseable, Serializable {
private static final long serialVersionUID = 2119420428331150924L; private static final long serialVersionUID = 2119420428331150924L;
private long handle; private long handle;
private static int instanceCount = 0;
native long init(); native long init();
native void release(long handle); native void release(long handle);
public «$cname»() { public «$cname»() {
handle = init(); handle = init();
instanceCount++;
} }
private native long _«$cname»( private native long _«$cname»(
@ -52,6 +54,7 @@ tstylesheet {
public «$cname»(String mime_text) { public «$cname»(String mime_text) {
byte[] _mime_text = Utils.toUTF8(mime_text); byte[] _mime_text = Utils.toUTF8(mime_text);
handle = _«$cname»(_mime_text); handle = _«$cname»(_mime_text);
instanceCount++;
} }
private native byte[] _encodeMIME() throws pEpException; private native byte[] _encodeMIME() throws pEpException;
@ -62,11 +65,17 @@ tstylesheet {
private «$cname»(long h) { private «$cname»(long h) {
handle = h; handle = h;
instanceCount++;
} }
public final void close() { public final void close() {
release(handle); release(handle);
handle = 0; handle = 0;
instanceCount--;
}
public static int getInstanceCount() {
return instanceCount;
} }
final protected long getHandle() { final protected long getHandle() {

Loading…
Cancel
Save