public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: abhishek desai <abhi00@gmail.com>
To: java@gcc.gnu.org
Subject: Calling the garbage collector.
Date: Mon, 27 Jul 2009 09:41:00 -0000	[thread overview]
Message-ID: <898285d30907270241h2a5a74abu8ae9a849399b8192@mail.gmail.com> (raw)

Hi,

I have a simple java program to test the garbage collection. It has
the two java files shown below.

TestClass.java

public class TestClass {
        protected void finalize() throws Throwable {
                System.out.println("Java TestClass finalizer called.");
        }
}


HelloWorld.java

import TestClass;

class HelloWorld
{
        public static void main(String args[]) {
                System.out.println("HelloWorld\n");

                TestClass a =  new TestClass();
                a = null;
                System.gc();
        }
}


When I compile this using javac to a class file and run the bytecode
using the 'java' interpreter, the finalize funtion for TestClass.java
is called.
When I compile the same set of files using gcj to machine code, the
finalizer is not called. Can any one tell me why this happens and what
I will have to do to get the finalizer called when object is no longer
used.

             reply	other threads:[~2009-07-27  9:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-27  9:41 abhishek desai [this message]
2009-07-27 10:07 ` Andrew Haley
2009-07-27 14:43   ` BGB
2009-07-27 15:37 Chris Gray
2009-07-27 16:16 ` BGB

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=898285d30907270241h2a5a74abu8ae9a849399b8192@mail.gmail.com \
    --to=abhi00@gmail.com \
    --cc=java@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).