mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 22:02:49 -06:00
Examples: AndroidMath: Java9 compatibility fixed - finalizers can not be used.
git-svn-id: svn://ultimatepp.org/upp/trunk@16026 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
181edf9277
commit
e96f8d39c7
3 changed files with 12 additions and 9 deletions
|
|
@ -13,15 +13,15 @@ public class Vector
|
|||
private long nativeAdress = 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
@Override
|
||||
protected void finalize() throws Throwable
|
||||
protected void dispose()
|
||||
{
|
||||
nativeFinalize();
|
||||
super.finalize();
|
||||
nativeDispose();
|
||||
}
|
||||
|
||||
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 nativeFinalize();
|
||||
private native void nativeDispose();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue