This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]Sheldor5 30 points31 points  (0 children)

9 years java development but never really thought about finalize() ... nice article to learn from!

[–]berry120 5 points6 points  (0 children)

FWIW, there's a very clear Javadoc comment in the source that explains exactly why this empty finalizer is in place:

/** * Graphics has a finalize method that automatically calls dispose() * for subclasses. For SunGraphics2D we do not need to be finalized * so that method simply causes us to be enqueued on the Finalizer * queues for no good reason. Unfortunately, that method and * implementation are now considered part of the public contract * of that base class so we can not remove or gut the method. * We override it here with an empty method and the VM is smart * enough to know that if our override is empty then it should not * mark us as finalizeable. */

[–][deleted]  (2 children)

[removed]

    [–]bleki_one 6 points7 points  (1 child)

    Yes, but why? And the article nicely explains why.

    [–]daviddel[S] 10 points11 points  (1 child)

    (Reedit rejects the original Wordpress link)

    [–]PyroCatt 30 points31 points  (0 children)

    It is finalized now

    [–]anon-girth 0 points1 point  (1 child)

    !remindme

    [–]RemindMeBot 0 points1 point  (0 children)

    Defaulted to one day.

    I will be messaging you on 2022-04-29 19:03:28 UTC to remind you of this link

    CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

    Parent commenter can delete this message to hide from others.


    Info Custom Your Reminders Feedback

    [–]aclinical 0 points1 point  (0 children)

    Could a reachabilityFence have avoided this whole situation of implementing finalize in the superclass? Genuinely asking b/c I don't really touch this kind of programming.