This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] handle menu bar removal/disposal


>>>>> "Kim" == Kim Ho <kho@redhat.com> writes:

I realize you withdrew this patch, but I wanted to bring up a point
about finalization.

Kim>  - add a finalize for MenuComponents, since they have no dispose

Kim> +protected void
Kim> +finalize() throws Throwable
Kim> +{
Kim> +  removeNotify();
Kim> +  super.finalize();
Kim> +}

It's better and more robust to have a finalize() method clean up only
things directly associated with that object itself.  E.g., in this
case, removeNotify() uses peer.dispose(), so it would be better to
simply have the peer clean up after itself.  This is preferred since
the order of finalization isn't guaranteed.

So, let's put the finalize method on the peer, not here.  Or we could
have a PhantomReference for each peer and a ReferenceQueue that knows
how to clean up after the peer is collected.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]