Remove confusing comments and add in extra clarification - Bug #1534931

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9431 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2006-10-11 22:32:15 +00:00
commit 26548e47fc
2 changed files with 3 additions and 15 deletions

View file

@ -16,13 +16,6 @@
<p>
This example illustrates how to use directors to implement C++ callbacks in Java.
</p>
<p>
Please note that unlike Python, Java does not have an equivalent concept of
weak references, so the program has to manually clean up after objects. The
implication of this is that the <code>Caller</code> class cannot claim
ownership of the <code>Callback</code> object in <code>Caller.setCallback()</code>
and delete it.
</p>
<hr>
</body>

View file

@ -21,14 +21,6 @@ public class main
caller.call();
caller.delCallback();
// Unlike Python, Java does not automatically support "weak"
// references (*), so we're left with managing the memory.
//
// (*) Yes, there is a WeakReference class, but it doesn't
// work exactly the way the Python weak reference works.
callback.delete();
callback = new JavaCallback();
System.out.println();
@ -39,6 +31,9 @@ public class main
caller.call();
caller.delCallback();
// Test that a double delete does not occur as the object has already been deleted from the C++ layer.
// Note that the garbage collector can also call the delete() method via the finalizer (callback.finalize())
// at any point after here.
callback.delete();
System.out.println();