From 26548e47fc87d67da576fa503ecb269702968d91 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 11 Oct 2006 22:32:15 +0000 Subject: [PATCH] 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 --- SWIG/Examples/java/callback/index.html | 7 ------- SWIG/Examples/java/callback/main.java | 11 +++-------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/SWIG/Examples/java/callback/index.html b/SWIG/Examples/java/callback/index.html index 1d890f888..c36c63d6c 100644 --- a/SWIG/Examples/java/callback/index.html +++ b/SWIG/Examples/java/callback/index.html @@ -16,13 +16,6 @@

This example illustrates how to use directors to implement C++ callbacks in Java.

-

-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 Caller class cannot claim -ownership of the Callback object in Caller.setCallback() -and delete it. -


diff --git a/SWIG/Examples/java/callback/main.java b/SWIG/Examples/java/callback/main.java index 9e7af267e..4800f8cc9 100644 --- a/SWIG/Examples/java/callback/main.java +++ b/SWIG/Examples/java/callback/main.java @@ -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();