Examples, Android: reverted last change.

git-svn-id: svn://ultimatepp.org/upp/trunk@16027 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
klugier 2021-07-19 21:06:16 +00:00
parent e96f8d39c7
commit 5e35e7ae7e
3 changed files with 9 additions and 12 deletions

View file

@ -58,9 +58,6 @@ public class AndroidMathActivity extends Activity
text += "Vec2: " + vec2.toString() + "\n";
tv.append(text);
vec1.dispose();
vec2.dispose();
}
static {

View file

@ -30,7 +30,7 @@ extern "C" {
mm.MakeCopy(env, jobjThis, jobjThat);
}
JNIEXPORT void JNICALL Java_org_upp_AndroidMath_Vector_nativeDispose(
JNIEXPORT void JNICALL Java_org_upp_AndroidMath_Vector_nativeFinalize(
JNIEnv *env,
jobject obj)
{

View file

@ -13,15 +13,15 @@ public class Vector
private long nativeAdress = 0;
/**
* In order to avoid memory leaks on the native side. The cleaning method needs to be
* called.
*
* In previous version of this example finalize method was used. However, in Java 9 the
* finalize method was deprecated and we can not longer relay on them.
* We override finalize method, because we need to destroy native c++ object when
* there is not more reference to Java object. This method is called by default
* by garbage collector.
*/
protected void dispose()
@Override
protected void finalize() throws Throwable
{
nativeDispose();
nativeFinalize();
super.finalize();
}
public Vector(int size)
@ -46,5 +46,5 @@ public class Vector
private native void construct(int size);
private native void copyConstruct(Vector vec);
private native void nativeDispose();
private native void nativeFinalize();
}