From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8725 invoked by alias); 27 Jul 2009 09:41:26 -0000 Received: (qmail 8638 invoked by uid 22791); 27 Jul 2009 09:41:25 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_46,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-qy0-f195.google.com (HELO mail-qy0-f195.google.com) (209.85.221.195) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Jul 2009 09:41:15 +0000 Received: by qyk33 with SMTP id 33so4001202qyk.0 for ; Mon, 27 Jul 2009 02:41:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.85.132 with SMTP id o4mr1340623qcl.0.1248687673034; Mon, 27 Jul 2009 02:41:13 -0700 (PDT) Date: Mon, 27 Jul 2009 09:41:00 -0000 Message-ID: <898285d30907270241h2a5a74abu8ae9a849399b8192@mail.gmail.com> Subject: Calling the garbage collector. From: abhishek desai To: java@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg00068.txt.bz2 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.